When you programatically setFieldValue and update validationSchema, formik still displays errors. It will remove errors once you update formik in any way, it validates form based on new values but old schema
Expected behavior
When you programatically setFieldValue and update validationSchema, formik will revalidate form based on new schema and new value
Reproducible example
The example shows initially validated form.
Please click 'remove validation' which will remove value and validation at the same time.
You should see no error but there are.
You can check that validation is passed correctly by focusing and blurring the input field or just clicking validateForm() button
Suggested solution(s)
Formik should add useEffect to perform validation when validationSchema is changed.
Validation should be done based on validationSchema from useRef, not props.
🐛 Bug report
Current Behavior
When you programatically setFieldValue and update validationSchema, formik still displays errors. It will remove errors once you update formik in any way, it validates form based on new values but old schema
Expected behavior
When you programatically setFieldValue and update validationSchema, formik will revalidate form based on new schema and new value
Reproducible example
The example shows initially validated form. Please click 'remove validation' which will remove value and validation at the same time. You should see no error but there are. You can check that validation is passed correctly by focusing and blurring the input field or just clicking validateForm() button
Suggested solution(s)
Formik should add useEffect to perform validation when validationSchema is changed. Validation should be done based on validationSchema from useRef, not props.
Additional context
Similar problems: https://github.com/jaredpalmer/formik/issues/1833 https://github.com/jaredpalmer/formik/issues/2266
Your environment