You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm dealing with an issue very similar to the one described here and I'm not that familiar with react-select so perhaps I missed something in the docs that would help me.
I'm using react-select inside a Formik form and I need to be able to receive new values and update the entire form. By using Formik's setFieldValue() I'm able to populate the form with new values but the react-selects aren't displaying their new value. I'm also using setFieldValue() for the selects onChange and it does update the values so I don't understand why I'm not able to use it to set values as well.
After the form gets populated with new values and I check the contents of the selects, I'm able to see that they contain a label (which Formik calls name?) and value with data in it
But the input itself will be empty (see City below) until another option is "manually" selected (which is what I did with Subdivision/SubdivisionName to show that both fields contain the same data structure and somehow works fine with onChange())
The only way I've been able to sort of reach the solution I need is to set the new values as the placeholder, but this doesn't actually select it as far as I can tell and I need it to be as if I had just selected that option. I've tried using defaultValue but since it doesn't update then that won't work for what I need and using value did work but the onChange won't update the values.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I'm dealing with an issue very similar to the one described here and I'm not that familiar with react-select so perhaps I missed something in the docs that would help me.
I'm using react-select inside a Formik form and I need to be able to receive new values and update the entire form. By using Formik's
setFieldValue()
I'm able to populate the form with new values but the react-selects aren't displaying their new value. I'm also usingsetFieldValue()
for the selectsonChange
and it does update the values so I don't understand why I'm not able to use it to set values as well.After the form gets populated with new values and I check the contents of the selects, I'm able to see that they contain a label (which Formik calls name?) and value with data in it
But the input itself will be empty (see City below) until another option is "manually" selected (which is what I did with Subdivision/SubdivisionName to show that both fields contain the same data structure and somehow works fine with
onChange()
)The only way I've been able to sort of reach the solution I need is to set the new values as the placeholder, but this doesn't actually select it as far as I can tell and I need it to be as if I had just selected that option. I've tried using
defaultValue
but since it doesn't update then that won't work for what I need and usingvalue
did work but the onChange won't update the values.Thanks in advance for the help!
Beta Was this translation helpful? Give feedback.
All reactions