submitForm seems to not work if validate is async
See original GitHub issueWhen calling submitForm
and using validate
with async validations submitForm
never executes
- Formik Version: ^0.11.10
Issue Analytics
- State:
- Created 6 years ago
- Comments:9 (1 by maintainers)
Top Results From Across the Web
angular async validator not triggered on submit if user does ...
I enter a username and password, submit the form, and get an error such as "this account is not yet valid" from the...
Read more >Async Form Posts With A Couple Lines Of Vanilla JavaScript
In this tutorial we'll write a tiny JavaScript event handler that will post our HTML forms using fetch instead of the classic synchronous ......
Read more >Validation - Formik
Formik is designed to manage forms with complex validation with ease. Formik supports synchronous and asynchronous form-level and field-level validation.
Read more >useForm - setError - React Hook Form
This method will force set isValid formState to false , however, it's important to aware isValid will always be derived by the validation...
Read more >Handling form submission - Blazor University
The OnSubmit event is executed when the form is submitted, regardless of whether the form passes validation or not. It is possible to...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Having the same problem here, the example is a bit confusing. Tried to look at the source code and figure it out.
You have to return a promise (the example is resolving a promise and is either returning nothing or throwing an error)
Edited your codesandbox to have it working as expected here
btw the example could be be something along the lines of (if you really have to return a Promise)
it doesn’t really make sense, but it returns a promise in the end that is resolved inside formik.
You can also resolve a Promise like that in the
validate
function and return the errors as objectHere is another example of using Promise as return value of
validate
function that worksThanks for your availability @prichodko.
I have replicated it here
Based on the example on the README.md
never triggers