-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Fix validation on stale values #3947
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
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: f798575 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. |
|
@quantizor @jaredpalmer I've updated this branch, also added test. Could you take a look ? |
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.currentto thestatevariable this variable contains "old" value until next re-renderformik/packages/formik/src/Formik.tsx
Line 190 in 0f960aa
And then when
setFieldValueandsetFieldTouchedare called consecutivelystateRef.currentreferences to updated value imediatelly aftersetFieldValuecall, butstatevariable is still references to the old value andsetFieldTouchedruns validation on that old valueUsing
stateRef.currentdirectly gurantees that actual values are taken