-
Notifications
You must be signed in to change notification settings - Fork 49.4k
Description
React version: 19.1.0
useEffect does not run after changed dependencies, due to startTransition.
Steps To Reproduce
- Open the StackBlitz reproduction
- open the terminal
npm install
npm run start:dev
- Open the browser Developer Tools
- Select Console tab from the Developer Tools
- Load/reload the StackBlitz preview page
- Watch the Developer Tools console logs.
Link to code reproductions:
The current behavior
File src/main.hooks.ts
contains an hook named useData
. Inside this hook, the useEffect
at line 53
should be executed 2 times because dependencies change 2 times (first with value undefined
and second time with value 1
), but it is executed only once.
Following Developer Tools Console screenshot shows the issue.
The expected behavior
The useEffect
at line 53
should be executed 2 times because dependencies change 2 times (first with value undefined
and second time with value 1
).
Following Developer Tools Console screenshot shows the correct behavior.
Correct behavior can be achieved with one of these two workarounds:
- comment line
32
disabling thesetExample(ExampleInitialValue)
- de-comment line
38
enablingsetExample(ExampleInitialValue + 1)
More Details
In this screenshot I show a brief explanation of the hook flow.
