-
-
Notifications
You must be signed in to change notification settings - Fork 605
Description
Describe the bug
When going from one route to another one that has a tanstack form, all fields are set to default value initially and then undefined right after. This causes an error on UI.
Assume 2 routes / and /form and the /form route has the tanstack form. The problem only happens (as far as I can tell) when:
- User goes to
/route. - User clicks a link on the page that redirects them to
/formroute - All fields on the form are set to their default values first then to undefined
If you refresh the page in the above example, or you directly go to /form route by entering the URL on your address bar and pressing enter, the problem doesn't occur. It appears that this only happens while routing the user from one page in the app to the /form page.
Your minimal, reproducible example
https://codesandbox.io/p/devbox/pf2wkh
Steps to reproduce
- Go to "/" route and open the console
- Click "Go to Form" link to go to "/form"
- Notice on the console prints:
email value default@gmail.com
password value 123456789
email value undefined
password value undefined
If you are running on strict mode you'll see logs twice due to double render
- If you refresh the page you'll notice that they are not set to undefined
Expected behavior
Fields shouldn't be set to undefined
How often does this bug happen?
Every time
Screenshots or Videos
No response
Platform
- OS: MacOS
- Browser: Edge
- 143.0.3650.96 (arm64)
TanStack Form adapter
react-form
TanStack Form version
1.28.5
TypeScript version
^5
Additional context
No response