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

未关闭
#1,798 13 条评论 4 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
45/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
停滞
技术栈
react, typescript
领域
frontend

调研方向

从链接的 StackBlitz 复现开始,比较启用第 12 行与启用第 13 行时的行为。跟踪重置为新值时如何与 useStore 订阅交互,然后验证重置后输入仍保留 x === 5 和 date === new Date(2025, 0, 1)。

由索引模型根据 Issue 内容生成。

描述

v1 v2: needs investigation
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

主要语言
TypeScript
星标
6.8k
派生
705
平均合并
1 天 7 小时
30 天内合并 PR
13

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

TanStack/form 的其他 Issue

查看 TanStack/form 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。