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); }} /> )}
</Formik>;
Though, it’s worth noting that formik is no longer being maintained as per this discussion: https://github.com/jaredpalmer/formik/issues/3613
Work with our skilled React developers to accelerate your project and boost its performance.
Hire Reactjs Developers