onSubmitAsync validator executing twice when submiting a form
I have a login form where I validate if the email and password are correct in the onSubmitAsync validator. However, in every case the validator gets called twice. I can see it in the browser console and in my api where I see two requests being made. I do not want this behaviour. I don't know if I set it up wrong or it is a bug. If you are able to help me I would very much appreciate it!
3 Replies
other-emerald•11mo ago
I can reproduce this by adding a console.log/debugger to the in this example:
https://tanstack.com/form/latest/docs/framework/react/examples/field-errors-from-form-validators
When filling the form with the data:
test
and 14
I get this log statements:
When I remove the randomness (Math.random) from the sleep
call the time between the two calls to onSubmitAsync appear to be the the setTimeout-time.inland-turquoiseOP•11mo ago
You are right. So do you think that is how it's supposed to behave or it's a bug?
other-emerald•11mo ago
I would say it's unwanted behaviour… Could you open a Issue on the Github Repo?