Skip to content

Document attaching multiple refs to one element in useRef - #8578

Open
smg99 wants to merge 1 commit into
reactjs:mainfrom
smg99:docs/use-ref-multiple-refs
Open

Document attaching multiple refs to one element in useRef#8578
smg99 wants to merge 1 commit into
reactjs:mainfrom
smg99:docs/use-ref-multiple-refs

Conversation

@smg99

@smg99 smg99 commented Aug 5, 2026

Copy link
Copy Markdown

Fixes #7251

Summary

  • Add a new useRef troubleshooting section: "How can I attach more than one ref to a single element?"
  • Show a compiler-safe pattern using a ref callback to assign the same DOM node to multiple refs
  • Cover both object refs and callback refs in the example

Why

Issue #7251 asks for docs guidance on combining multiple refs on one element (for example local + forwarded refs) without relying on patterns that read ref.current during render.

Validation

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

@smg99

smg99 commented Aug 5, 2026

Copy link
Copy Markdown
Author

Requesting review for this docs addition.

This PR adds a useRef troubleshooting section showing how to attach multiple refs to one element with a ref callback, including object refs and callback refs. The intent is to provide a compiler-safe pattern without reading ref.current during render.

Happy to adjust placement or wording.

@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]: Documentation for useRef should tell us how to deal with multiple refs on a single element

1 participant