Description
Do you want to request a feature or report a bug?
Bug
What is the current behavior?
It seems useEffect(effect, [ref.current])
is re-running under certain circumstances without the current ref identity changing.
If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem. Your bug will get fixed much faster if we can run your code and it doesn't have dependencies other than React:
https://codesandbox.io/s/qkzl9xjj44
What is the expected behavior?
In this example, the effect should only be run once, not re-run (and thus cleaned up) upon clicking the button for the first time. The isActive
state should be returned to false on mouseup. CLEAN UP!
should not be logged to the console since the ref hasn't been reassigned.
Which versions of React, and which browser / OS are affected by this issue? Did this work in previous versions of React?
16.7.0-alpha.2 (affects all environments)