Open chungweileong94 opened 3 months ago
Probably not related, but I actually found this bug because one of my server toast hack stopped working during deployment in the NextJS 15 RC, where I was trying to read a maxAge: 0
cookie after a redirect. It was working before, so it got me thinking if some behavior changed that broke my hack and also the useEffect
.
This is a bug in React that's already been reported. Double invocation currently doesn't work during hydration in the React 19 RC. Mounts during client-side updates will double invoke Effects in Strict Mode.
Link to the code that reproduces this issue
https://github.com/chungweileong94/nextjs-strict-mode-useeffect-bug
To Reproduce
Current vs. Expected behavior
Expected:
useEffect
code should run twice in development mode, which should show some errors (or double "effect" logs) in the consoleCurrent:
useEffect
code only run once.Provide environment information
Which area(s) are affected? (Select all that apply)
Developer Experience
Which stage(s) are affected? (Select all that apply)
next dev (local)
Additional context
I tested the other strict mode behavior (double re-rendering), and it seems to be working. However, the double
useEffect
doesn't seem to work as expected according to the React documentation.