Skip to content

Double render without triggering useEffect twice #1841

@marzelc

Description

@marzelc

Describe the bug

When using a useStore to retrieve information from the form (in the example a value but it could be something else), the component renders a first time, the useEffect is triggered, then a second render is performed without useEffect and without being seen in the React profiler.

Your minimal, reproducible example

https://codesandbox.io/p/devbox/blissful-mccarthy-2nl2s2?file=%2Fsrc%2Findex.tsx%3A8%2C56

Steps to reproduce

  1. Open the sandbox
  2. Show the devTolls
  3. Enter t in firstName
  4. Looks at the logs you should see (it can be a little bit random, you can try again)
render component with useStore
useEffect of component with useStore
render component with useStore

Expected behavior

There should be only one render with one useEffect.

How often does this bug happen?

Often

Screenshots or Videos

No response

Platform

  • OS: MacOs
  • Browser: Chrome
  • Version: 142.0.7444.60

TanStack Form adapter

react-form

TanStack Form version

1.23.8

TypeScript version

No response

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions