Skip to content

Clarify ref callback cleanup behavior in common ref docs - #8579

Open
smg99 wants to merge 1 commit into
reactjs:mainfrom
smg99:docs/clarify-ref-callback-cleanup
Open

Clarify ref callback cleanup behavior in common ref docs#8579
smg99 wants to merge 1 commit into
reactjs:mainfrom
smg99:docs/clarify-ref-callback-cleanup

Conversation

@smg99

@smg99 smg99 commented Aug 5, 2026

Copy link
Copy Markdown

Fixes #7811

Summary

  • Clarify the ref callback behavior when callbacks change between renders
  • Explicitly describe the cleanup-function path as the primary behavior
  • Clarify that passing null to the old callback is legacy fallback behavior when no cleanup is returned

Why

Issue #7811 points out ambiguity in the current wording, especially around when React calls a previous callback with null. This change aligns wording with current React 19 cleanup semantics while preserving backwards-compatibility notes.

Validation

  • Ran yarn lint
  • Ran yarn lint-heading-ids

@smg99

smg99 commented Aug 5, 2026

Copy link
Copy Markdown
Author

Requesting review for this wording clarification.

This updates the ref callback section to emphasize the cleanup-function path first, and clarifies that null is the legacy fallback when no cleanup function is returned.

Happy to refine wording further if maintainers prefer a different phrasing.

@github-actions

github-actions Bot commented Aug 5, 2026

Copy link
Copy Markdown

Size changes

Details

📦 Next.js Bundle Analysis for react-dev

This analysis was generated by the Next.js Bundle Analysis action. 🤖

This PR introduced no changes to the JavaScript bundle! 🙌

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Suggestion]: clarify behaviour of ref callbacks

1 participant