Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Form options are stale after submit #1051

Open
sxriff opened this issue Dec 2, 2024 · 0 comments
Open

Form options are stale after submit #1051

sxriff opened this issue Dec 2, 2024 · 0 comments

Comments

@sxriff
Copy link

sxriff commented Dec 2, 2024

Describe the bug

I want to disable the submit button after the submission. I compare options.defaultValues and values from the store to determine whether they are equal. However, the next render after submission contains stale options. This happens likely because of the useIsomorphicLayoutEffect that updates the options here. I wonder maybe the formApi.update can be called during the render

Your minimal, reproducible example

https://codesandbox.io/p/sandbox/elated-brahmagupta-sj6mvk

Steps to reproduce

  1. Type "Johny" in the input
  2. Click the submit button
  3. Click the submit button again

Expected behavior

As a user, I expect that the submit button is disabled after the first click, but it becomes disabled only after the second click

How often does this bug happen?

Every time

Screenshots or Videos

No response

Platform

  • OS: Windows
  • Browser: Chrome

TanStack Form adapter

react-form

TanStack Form version

v0.39.0

TypeScript version

v4.4.4

Additional context

If the useQuery is replaced with a useState then everything works as expected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant