Bug: Problem with StrictMode in development (useEffect + useRef/Memo). useEffect ignores first value of useRef/Memo and uses second twice #31607
Labels
Status: Unconfirmed
A potential issue that we haven't yet confirmed as a bug
React version 18.3.1
StrictMode renders everything twice. and if the useRef value changes on the second render useEffect uses second version of useRef twice.
That can cause some memory leaks during development and unexpected behavior for useEffect
output:
the problem with that is the reference to the first object 0.2675... was lost
and the second object 0.3384... was cleared and used again
That breaks the program if the useRef/Memo should return the cleanup callback with the object
e.g
because it's going to do the cleanup for the newest object immediately after connection and loose the refference to object created during the first render
The text was updated successfully, but these errors were encountered: