Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

192
Views
How to use values from Formik initial values and pass them back into React Select?

I've currently implemented a means of setting my Formik initial values from an API call which is all working fine but I'm currently facing an issue with re-populating my react-select field from my initial values.

At the moment, my initial values (snippet) from API fetch call looks like this:

const emptyGroup = {
       groupName: "",
       groupValues: []
}

const INITIAL_FORM_STATE = {
  myName: '',
  allGroups: [emptyGroup]
};

"allGroups": [
    {
      "groupName": "Group Astro",
      "groupValues": [
           {
             "value": "My Group A",
             "label": "My Group A"
           },
           {
             "value": "My Group B",
             "label": "My Group B"
           }
      ]
    }
]

Below is my react-select component:

<ReactSelect
   options={ myGroupOptions }   
   isMulti={true}
   name={`allGroups.${index}.groupValues`}
   onChange={(option) => formikProps.setFieldValue({`allGroups.${index}.groupValues`}, option.value)}
   onBlur={formikProps.handleBlur}
   value={ ????? }
 />

What I am unsure is, how do I feed the values from the groupValues array above back into value={ ?????? } so that when this <ReactSelect /> component is rendered, it displays the values: My Group A My Group B within it?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Just in case someone else comes across this issue/query, I managed to solve the issue as follows for value together with formik values:

<ReactSelect
   options={ myGroupOptions }   
   isMulti={true}
   name={`allGroups.${index}.groupValues`}
   onChange={(option) => formikProps.setFieldValue({`allGroups.${index}.groupValues`}, option.value)}
   onBlur={formikProps.handleBlur}
   value={values.allGroups[index].groupValues}
 />
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!