TanStack / form

🤖 Powerful and type-safe form state management for the web. TS/JS, React Form, Solid Form, Lit Form and Vue Form.
https://tanstack.com/form
MIT License
3.47k stars 316 forks source link

When you render `Field` conditionally first rendered field will override all next rendered fields #808

Open vara855 opened 3 days ago

vara855 commented 3 days ago

Describe the bug

Use case:

I want to render different Field components according to some condition of form state.values.

It used to work in previous versions (0.21=<).

Your minimal, reproducible example

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

Steps to reproduce

  1. go to https://stackblitz.com/edit/vitejs-vite-dvwuju?file=src%2FApp.jsx
  2. fill input
  3. click checkbox
  4. check values of form

Expected behavior

I expected that values firstField value will dissapear from state when you uncheck checkbox and secondField value will be stored in state.

How often does this bug happen?

Every time

Screenshots or Videos

No response

Platform

Arc browser

TanStack Form adapter

react-form

TanStack Form version

v0.25.1

TypeScript version

=v5.4.5

Additional context

No response

vara855 commented 3 days ago

upd: You may fix it if you render it under different Subscribe components. But it feels like a bug...