-
-
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
Make formik sync when validation functions are sync #3976
base: main
Are you sure you want to change the base?
Make formik sync when validation functions are sync #3976
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 1 Skipped Deployment
|
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. |
🦋 Changeset detectedLatest commit: a0b17a6 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 |
@jaredpalmer This change goes in the direction that you are mentioning in #2140 but is backwards compatible since it's not removing any functionality. The deprecation of the async validation methods could be done in a later stage so we can first make things more synchronous (which will improve performance of a lot of apps) and then proceed with the removal of the async stuff. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👏🏻 Well done. Amazing update
…en-synchronous Fix bug when initializing the form when validation is synchronous
@fbarbare could you update against |
Would love to see the benchmarks run for this vs current |
…unctions-are-sync
@quantizor Thanks for looking at this PR! I have updated the branch with |
@@ -0,0 +1,5 @@ | |||
--- | |||
'formik': minor |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@quantizor we might want to make this a major version bumb in the end.
I had not thought of that initially but if anyone implemented things as setFieldValue(..).catch(...)
then it would break if their validation functions would be sync. It would be completely fine if they would implement it as await setFieldValue(..)
or void setFieldValue(..)
though.
What are your thoughts?
…unctions-are-sync
…unctions-are-sync
When the given validation function are synchronous there is no reason to make them async. Making them async actually makes the whole code much slower and creates unecessary re-renders.