4 Replies
rising-crimsonOP•8mo ago
jolly-crimson•8mo 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.rare-sapphire•7mo 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.jolly-crimson•7mo 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