TanStackT
TanStack11mo ago
3 replies
unexpected-ivory

canSubmit behavior is described inaccurately in documentation

In the documentation, the canSubmit property of the form state object is described as a "flag that is false when any field is invalid and the form has been touched". This doesn't accurately describe it's true behavior.

I've got a Next.js project where I'm using client and server validation in the same form. The following happens:

1. I fill out the form properly and canSubmit becomes true
2. I submit the form which doesn't pass server validation
3. The errors property of the form state object is now set, canSubmit is still true
4. I submit the same values again which still don't pass server validation
5. The errors property of the form state object remains the same, canSubmit is now false

What I'm getting at is that it seems like canSubmit also takes the form errors into account, not just any invalid field, and it's also flakey. Maybe something to do with the order in which things are happening.

Has anyone else experienced this behavior?
Was this page helpful?