You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Suggestion]: clarify behaviour of ref callbacks #7811
React will also call your ref callback whenever you pass a different ref callback. In the above example, (node) => { ... } is a different function on every render. When your component re-renders, the previous function will be called with null as the argument, and the next function will be called with the DOM node.
If I understand correctly, the emphasised sentenced is not correct when the ref callback returns a clean up function, as is the case in the referenced example. This needs to be clarified.
There is a note later on which helps a bit, but I still think this sentence could be made clearer so it makes sense in isolation.
Yeah this could be cleaned up, want to submit a PR to improve it? It should probably flip so it emphasizes the ref callback pattern and has a note about legacy support with passing null when there's no cleanup.
Activity
rickhanlonii commentedon May 16, 2025
Yeah this could be cleaned up, want to submit a PR to improve it? It should probably flip so it emphasizes the ref callback pattern and has a note about legacy support with passing null when there's no cleanup.
smg99 commentedon Aug 5, 2026
Opened PR #8579 to address this clarification:
#8579
It updates the
refcallback wording to prioritize cleanup semantics and clarifies whennullis used as fallback.