How to Bind React-select with Formik

Like a normal input, we can’t bind formik’s handleChange to React-select’s onChange directly since it gives selectedValue object in the call back parameter instead of an event. So, we need to utilize formik’s setFieldValue instead as per below example:

<Formik {...initialValues}> 
{({ values, setFieldValue }) => 
( <ReactSelect name="selectValue" value={values.selectValue} 
options={optionsList} onChange={(selectedOption) => 
{ setFieldValue("selectValue", selectedOption); }} /> )} 

Though, it’s worth noting that formik is no longer being maintained as per this discussion:

Subscribe for
weekly updates