TanStack / TanStack/form

Reset form does not work as expected in combination with `useStore`

Open
#1,798 13 comments 4 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

v1 v2: needs investigation
Dominant language
TypeScript
Stars
6.7k
Forks
682
Avg merge
5d 18h
Merged PRs (30d)
7

Description

Describe the bug

I realize there are some related issues (https://github.com/TanStack/form/issues/1490) but I think there are still some bugs somewhere.

It seems like after resetting to new values, subscribing to the state of those new values reverts them to the default values.

Your minimal, reproducible example

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

Steps to reproduce
  1. go to sandbox
  2. observe x === 1 and date === new Date() in the input fields. this is incorrect.
  3. comment out line 12 and comment in line 13
  4. observe x === 5 and date === new Date(2025, 0, 1) in the input fields. this is correct.
Expected behavior

x === 5 and date === new Date(2025, 0, 1)

How often does this bug happen?

Every time

Screenshots or Videos

No response

Platform
  • macOS
  • brave
  • 1.82
TanStack Form adapter

react-form

TanStack Form version

v1.19.5

TypeScript version

No response

Additional context

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked StackBlitz reproduction and compare the behavior with line 12 enabled versus line 13 enabled. Trace how resetting to new values interacts with the useStore subscription, then verify that the inputs retain x === 5 and date === new Date(2025, 0, 1) after the reset.

Written by the indexing model from the issue text.

Assessment

Tech stack
react, typescript
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.