#3754·formik

Multiple calls to setFieldValue inside async action result in form errors

Author: matt-sandersCreated Apr 12, 2023Updated Sep 17, 2026
LabelsType: Bug

Bug report

Current Behavior

We have a use case where fields need to be updated as the result of an async function, very similar to this example. However, we would like to update multiple fields. We find that when we use setValues things work as expected, however when we make multiple calls to setFieldValue it results in an error.

This doesn't happen if the calls to setFieldValue happen as an immediate callback ( e.g. from a button ) but when the callback happens after an async action, things go a little awry.

The obvious, initial solution is to just use setValues, but we may want to update these fields individually given certain circumstances ( e.g. if x, then update y but not z )

Expected behavior

Multiple calls to setFieldValue should not trigger validation errors when the form is valid.

Reproducible example

Live example: https://d4pe7b.csb.app/

Codesandbox: https://codesandbox.io/s/proud-wind-d4pe7b?file=/src/App.js

Your environment

Software Version(s)
Formik 2.2.9
React 18.2.0
TypeScript -
Browser Chrome
npm/Yarn npm
Operating System MacOS