• python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Facebook Twitter Instagram
Devs Fixed
  • python
  • javascript
  • reactjs
  • sql
  • c#
  • java
Devs Fixed
Home ยป Resolved: React-Select component not displaying values stored within Formik’s state values

Resolved: React-Select component not displaying values stored within Formik’s state values

0
By Isaac Tonny on 18/06/2022 Issue
Share
Facebook Twitter LinkedIn

Question:

I am using react-select within a MUI stepper together with Formik.
My values for the react-select component are stored correctly within Formik’s state but when I go back a step and then forward again (mui stepper), my react-select component loses the values even though it’s still in Formik’s state.
Just displays the placeholder value – “Fields”.
My code is as follows:
Here are the selected fields within Formik’s state:
All seems fine at selection but unsure why my <ReactSelect /> component doesn’t re-display the values from Formik’s state (selectedFields) when going back and forth through MUI’s stepper.
Not sure what I am missing?

Answer:

It looks like you never set the value for the react-select. Try something like this:

If you have better answer, please add a comment about this, thank you!

formik react-select reactjs
Share. Facebook Twitter LinkedIn

Related Posts

Resolved: PyCharm cannot see my newly compiled .pyc see on import

27/03/2023

Resolved: I am facing ERR_HTTP2_PROTOCOL_ERROR on my website

27/03/2023

Resolved: TypeScript does not recognize properties when instantiating interface array

27/03/2023

Leave A Reply

© 2023 DEVSFIX.COM

Type above and press Enter to search. Press Esc to cancel.