Make formik sync when validation functions are sync#3976
Make formik sync when validation functions are sync#3976fbarbare wants to merge 10 commits intojaredpalmer:mainfrom
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. |
bonimba
left a comment
There was a problem hiding this comment.
👏🏻 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.
@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.