Skip to content
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

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
5 changes: 5 additions & 0 deletions .changeset/make-formik-possibly-synchronous.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'formik': minor
Copy link
Author

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?

---

Formik might not need to run asynchronously, it all depends on the validation functions. This change makes it all run synchronously if the validation functions do not return any promise, making all the updates much faster and creating les re-renders.
Loading