jaredpalmer / formik

Build forms in React, without the tears 😭
https://formik.org
Apache License 2.0
34k stars 2.79k forks source link

Make formik sync when validation functions are sync #3976

Open fbarbare opened 5 months ago

fbarbare commented 5 months ago

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.

vercel[bot] commented 5 months ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Skipped Deployment | Name | Status | Preview | Comments | Updated (UTC) | | :--- | :----- | :------ | :------- | :------ | | **formik-docs** | ⬜️ Ignored ([Inspect](https://vercel.com/formik/formik-docs/G35bsdQK7U3fswc3duomjEuYCXbs)) | [Visit Preview](https://formik-docs-git-fork-plentific-fb-make-formik-syn-f6eb9d-formik.vercel.app) | | Oct 15, 2024 1:37pm |
codesandbox-ci[bot] commented 5 months ago

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-bot[bot] commented 5 months ago

🦋 Changeset detected

Latest commit: a0b17a69d620a622ce67d8ac9cfa2b6f4c52c01f

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages | Name | Type | | ------------- | ----- | | formik | Minor | | formik-native | Patch |

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

fbarbare commented 5 months ago

@jaredpalmer This change goes in the direction that you are mentioning in https://github.com/jaredpalmer/formik/pull/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. Any thoughts?

quantizor commented 2 months ago

@fbarbare could you update against main when you get a moment? This branch looks awesome!

quantizor commented 2 months ago

Would love to see the benchmarks run for this vs current main as well

fbarbare commented 2 months ago

@quantizor Thanks for looking at this PR! I have updated the branch with main and also added a changeset.