Skip to content

form.reset during onSubmit ignores new default values #1681

Open

Description

@dragonautdev

Describe the bug

The issue is that if you use the form's reset function from inside the form's onSubmit with new default values, they will be ignored.
This only happens if used in combination with form store-related watches such as "isDirty"
From the troubleshooting done by @LeCarbonator , it appears to be a race condition between handleSubmit and reset.

Your minimal, reproducible example

https://stackblitz.com/edit/vitejs-vite-jd2ttqqx?file=src%2FApp.tsx

Steps to reproduce

  1. Uncheck the checkbox.
  2. Click the Submit button
  3. See how the form goes back to the original default values instead of the new ones.

Expected behavior

Since we are calling the reset function with new values, those values should become the new form values.

How often does this bug happen?

Every time

Screenshots or Videos

No response

Platform

  • OS: Any
  • Browser: Any
  • Node Version: 22

TanStack Form adapter

react-form

TanStack Form version

1.18.0

TypeScript version

v5.8.3

Additional context

A chat around this issue can be found here

Activity

  1. romulovalez commented on Aug 18, 2025

    @romulovalez

    +1, a workaround for now is to setTimeout(() => form.reset());

  2. djordje-st commented on Aug 19, 2025

    @djordje-st

    +1, a workaround for now is to setTimeout(() => form.reset());

    Unfortunately that doesn't work for me either

  3. dragonautdev commented on Aug 19, 2025

    @dragonautdev
    Author

    @romulovalez @djordje-st The setTimeout strategy works, but the amount of time you need to wait varies.

    when we discovered the issue, I had to set a timeout of up to 500ms for it to work.

  4. added
    v1This issue has been created during v1 development.
    on Aug 9, 2026
  5. LeCarbonator commented on Aug 11, 2026

    @LeCarbonator
    Contributor

    It looks like in v1, the check for new default values passed because

    • You create a new object on every render, which means that TanStack Form assumed new async data came in
    • Your newly created object is different from the resetted values, which means that TanStack Form assumed that your default values were stale

    It therefore updated the default values. isDirty was just an immediate way to cause a rerender of the component, but anything would have done it, like unrelated useStates.

    In v2, we have an equality check for both new default values as well as comparing your current state with the incoming values. This means that referential changes don't matter, but value changes do.

    20260811-1840-38.5806507.mp4
  6. added
    scope: reactThis issue specifically affects the react adapter.
    area: runtimeThis issue affects the runtime of the library.
    on Aug 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: runtimeThis issue affects the runtime of the library.scope: reactThis issue specifically affects the react adapter.type: bugThis is a bug in behaviour.v1This issue has been created during v1 development.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions