Replies: 1 comment
-
Hello! Is there any update on this by any chance? It would be really nice if validation on Submit could happen in parallel as long as the criteriaMode is set to "all" |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Currently, the code runs a sequential await on each field validation. Relevant part of code: https://github.com/react-hook-form/react-hook-form/blob/master/src/useForm.ts#L417
This can cause some pretty bad slowness on large forms that have validation that takes a long time or that is hitting an api. Not an issue on filling out the form, but it becomes noticeable on submit. CSB showing issue: https://codesandbox.io/s/react-hook-form-usefieldarray-nested-arrays-forked-ge4oq?file=/src/nestedFieldArray.js
Changing this to be a Promise.all would allow it to still fail fast, but would allow some of these to run in parallel, reducing the submit time to be roughly one field's validation vs the sum of all fields validation. The downside would be that the first field to fail validation wouldn't necessarily be the first field on the page.
I'm open to making this change and PR if it's something you'd accept, as well.
EDIT: As soon as I posted this, I realized I can probably use a resolver to accomplish this. Still think it'd be a good addition to the default.
Beta Was this translation helpful? Give feedback.
All reactions