Closed matomesc closed 1 year ago
I think, setValue returns a promise. I am attaching the codesandbox link with the working code. Updated code - https://codesandbox.io/s/formik-codesandbox-template-forked-f9s8d7?file=/index.js.
Also If you need to update multiple fields, why not send them all at once to setvalues instead of using it twice ?
It's weird in the docs (https://formik.org/docs/api/formik) and code (https://github.com/jaredpalmer/formik/blob/main/packages/formik/src/types.tsx#L91) the return value of setValues
is void
. But yes it does seem to return a promise. Maybe the docs / code should be updated to reflect the return of a promise.
I can fix the documentation for this. Looking at the function return type it seems like it's miss-matching with the one in the docs, so i'ill change the docs to reflect the one in the return type
Bug report
Current Behavior
I'm using the callback form of
setValues
like so to set multiple fields:But when calling it twice
prevValues
does not update to the new values.Expected behavior
prevValues
should always be updated to the newest values.Reproducible example
https://codesandbox.io/s/formik-codesandbox-template-forked-whzsh2?file=/index.js
Suggested solution(s)
Additional context
Your environment