-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refs in memoized elements #3695
Comments
Thank you for the awesome reproduction, after looking at this I can confirm this is an issue on our side. It seems related to keyed elements. Basically we see the key difference and rather than discarding the entire subtree we still reuse the |
That's funny because I added the key to simplify the example. My real use case doesn't use keys, it unmounts the So, maybe there are two issues. I'll wait until the one you are mentioning is fixed, and try again. Thanks. |
Describe the bug
Using
useRef
anduseMemo
together produces weird results.It's easier to explain with code:
The
console.log
logs null half of the times. I thinkref.current
should never be null.To Reproduce
Steps to reproduce the behavior:
null
logged half of the timeExpected behavior
ref.current
shouldn't be null. If I remove theuseMemo
it works as expected.React works as expected: https://codesandbox.io/s/condescending-gagarin-o29rj6?file=/src/App.js
The text was updated successfully, but these errors were encountered: