Skip to content

Form options are stale after submit #1051

Open
@sxriff

Description

@sxriff

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions