4 Replies
rare-sapphireOP•5mo ago
xenial-black•5mo ago
put the signIn call in the
validators.onSubmitAsync
parameter instead.
There will be two outcomes:
* The Signin has errors. Format them and return the errors in the validator. Tanstack Form will then know that the validators.onSubmitAsync
call failed and will not execute onSubmit
.
* The Signin was successful. Return undefined
. Tanstack Form will know that it was successful and execute the onSubmit
To summarize, validators are allowed to mutate data. Their return type simply informs tanstack on whether or not it should continue with the propagation
That's assuming that the error is form-related. If it's just any error, you should keep it in onSubmit
since the submission was fine.vicious-gold•4mo ago
I came here for this exact problem. I guess I can completely ignore
onSubmit
and solely use onSubmitAsync
since 99% of my forms require error handling.xenial-black•4mo ago
you can also treat onSubmit as a onSuccess callback in that case, so it still has its uses
redirecting to a new page, for example