Repository navigation
fix(shared): stop React 19 element.ref warnings from Link and tooltips - #7553
Merged
Merged
Conversation
React 19 logs "Accessing element.ref was removed in React 19" in dev whenever code reads `element.ref` on an element that has a ref prop. - next/link in legacyBehavior reads the child's `element.ref`. The shared Link now renders an `<a>` child that carries a ref (ProfileLink, SourceAvatarLink, TopStoryWidget) through next/link's default mode, with the anchor's props on the link, so its ref, handlers and classes reach the same `<a>`. Every other Link keeps legacyBehavior. - @tippyjs/react 4.2.6 (unmaintained) reads `children.ref` on every tooltip. A pnpm patch reads `children.props.ref` instead. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FodmVtyvRGwavusAekpEXw
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changes
Follow-up to the React 19 upgrade (#7545). In dev, React 19 logs "Accessing element.ref was removed in React 19" whenever code reads
element.refon an element that has a ref prop. Production was never affected.next/linkwithlegacyBehaviorreads the child'selement.ref. The sharedLinknow renders an<a>child that carries a ref (ProfileLink,SourceAvatarLink,TopStoryWidget) through next/link's default mode, with the anchor's props on the link, so the ref,onClickand classes land on the same<a>. Every otherLinkkeepslegacyBehavior, so the 470 other call sites are unchanged.@tippyjs/react4.2.6 (no longer maintained) readschildren.refon every tooltip. A pnpm patch (patches/@tippyjs__react@4.2.6.patch) readschildren.props.refinstead.Moving every
LinkofflegacyBehavior(Next'snew-linkcodemod) is a separate, larger change and isn't needed to clear these warnings.Events
Did you introduce any new tracking events?
No
Experiment
Did you introduce any new experiments?
No
Manual Testing
Caution
Please make sure existing components are not breaking/affected by this PR
next/linkwith a ref child logs the warning. The sharedLinkwith a ref'd<a>logs nothing, and keeps the ref on the<a>,href, class andonClick(withpreventDefaulthonored).ProfileLinkinsideBaseTooltipand a ref'd button insideBaseTooltiplog nothing and keep their refs.Generated by Claude Code
Preview domain
https://react-19-ref-warnings.preview.app.daily.dev