form
form copied to clipboard
React warning when setting defaultValue on conditionally rendered Field.
Describe the bug
React crashes if you set a Field level defaultValue on a conditionally rendered Field.
Cannot update a component (`App`) while rendering a different component (`Field`). To locate the bad setState() call inside `Field`, follow the stack trace as described in https://react.dev/link/setstate-in-render
at Field (https://tkj4dz.csb.app/node_modules/@tanstack/react-form/dist/esm/useField.js:43:23)
at APIField
at div
at form
at div
at App
Your minimal, reproducible example
https://codesandbox.io/p/sandbox/optimistic-golick-tkj4dz
Steps to reproduce
- Type something in First name so last name gets rendered
Expected behavior
Should not crash
How often does this bug happen?
Every time
Screenshots or Videos
No response
Platform
- OS: Windows 10
TanStack Form adapter
None
TanStack Form version
v0.41.3
TypeScript version
No response
Additional context
No response