I have a form with a complex validation logic that runs on the server.
Sometimes I am seeing stale validation errors being shown on the form.
This seems to happen in the following case
1) Form data is changed (and invalid)
2) Request to validate is sent to the server (not resolved yet) (REQUEST 1)
3) Form data is changed again (now with valid data)
3) Request to validate is sent to the server (not resolved yet) (REQUEST 2)
4) REQUEST 2 resolves and no validation error is shown
5) REQUEST 1 resolves and validation errors from prev invalid state is shown
Expected behavior
Reproducible example
The example below reproduces the error if you type in the input, then clear it and type again.
🐛 Bug report
Current Behavior
I have a form with a complex validation logic that runs on the server. Sometimes I am seeing stale validation errors being shown on the form. This seems to happen in the following case 1) Form data is changed (and invalid) 2) Request to validate is sent to the server (not resolved yet) (REQUEST 1) 3) Form data is changed again (now with valid data) 3) Request to validate is sent to the server (not resolved yet) (REQUEST 2) 4) REQUEST 2 resolves and no validation error is shown 5) REQUEST 1 resolves and validation errors from prev invalid state is shown
Expected behavior
Reproducible example
The example below reproduces the error if you type in the input, then clear it and type again.
Suggested solution(s)
The dispatch call here https://github.com/jaredpalmer/formik/blob/master/packages/formik/src/Formik.tsx#L333 should be aborted if the form values changes.
Additional context
Your environment