form icon indicating copy to clipboard operation
form copied to clipboard

`isSubmitting` does not toggle correctly after submission

Open chanithecat opened this issue 1 year ago • 1 comments

Describe the bug

When using useForm hook, the isSubmitting flag from the form instance does not toggle as expected after form submission. specifically the form.state.isSubmitting.

I am trying to use it by setting the input's disabled property to it so it would disable while submitting

<input
  type="password"
  placeholder="password"
  value={field.state.value}
  disabled={form.state.isSubmitting}
  onChange={(e) => field.handleChange(e.target.value)}
  onBlur={field.handleBlur}
/>

I tried using field.form.state.isSubmitting from the field directly but both have the same behavior.

Solved my issue by wrapping the form by <form.Subscribe> component but i would like to know if this is a bug.

Thank you in advance!

Your minimal, reproducible example

https://stackblitz.com/edit/github-tov4u8nn?file=src%2Froutes%2Findex.tsx

Steps to reproduce

  1. Submit the form.
  2. See the disabled input.

Expected behavior

I read the doc string of isSubmitting "A boolean indicating if the form is currently in the process of being submitted after handleSubmit is called." so i thought this will just toggle after validation

How often does this bug happen?

Every time

Screenshots or Videos

No response

Platform

  • OS: Arch
  • Browser: Zen Browser
  • Version: Mozilla Zen 1.14.11b

TanStack Form adapter

react-form

TanStack Form version

1.19.2

TypeScript version

5.7.2

Additional context

Thank you in advance!

chanithecat avatar Aug 19 '25 07:08 chanithecat

Sorry for not reading the docs

Tanstack Form doesn't cause re-renders when interacting with the form. So you might find yourself trying to use a form or field state value without success.

If you would like to access reactive values, you will need to subscribe to them using one of two methods: useStore or the form.Subscribe component.

using useStore solved it for me

chanithecat avatar Aug 19 '25 08:08 chanithecat