-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix validation on stale values #3947
base: main
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
🦋 Changeset detectedLatest commit: e004b64 The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. |
Helpful change. Are we pending one more review to get this merged? |
Thank you very much. I hope it will be released. |
Would love a test please |
I think I see some of the source of confusion, in formik/packages/formik/src/Formik.tsx Line 185 in c6ceb65
|
Any chance this can get merged and released? Seems like a helpful change to keep on the shelf. |
Fixes issue - #2083
The cause of the issue is in this line
formik/packages/formik/src/Formik.tsx
Line 185 in 0f960aa
beause of assigning value from
stateRef.current
to thestate
variable this variable contains "old" value until next re-renderformik/packages/formik/src/Formik.tsx
Line 190 in 0f960aa
And then when
setFieldValue
andsetFieldTouched
are called consecutivelystateRef.current
references to updated value imediatelly aftersetFieldValue
call, butstate
variable is still references to the old value andsetFieldTouched
runs validation on that old valueUsing
stateRef.current
directly gurantees that actual values are taken