[docs] Fix element.ref
accessing warning on docs
#45155
Merged
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.
Problem
Fix this warning (only visible on local):
To repro, simply checkout master, run docs and visit the homepage.
Solution
Remove the usage of
legacyBehavior
on the docs'Link
component (source). This legacy behavior relies on accessing the child ref, causing the warning:https://github.com/vercel/next.js/blob/38a6d0177eced9b56dfcc58f83662a659195af15/packages/next/src/client/link.tsx#L461
Here's the guide on removing this prop: vercel/next.js@489e65e.
I think we can remove it as the only thing we're doing on
NextLinkComposed
is adding an empty styled anchor, which Next'sLink
now does by default:https://github.com/vercel/next.js/blob/38a6d0177eced9b56dfcc58f83662a659195af15/packages/next/src/client/link.tsx#L621-L623
So:
legacyBehavior = true
, the result is the samelegacyBehavior = false
, as that would result in a nested anchor which is not valid HTML. I searched confirmed this in this repo, MUI X's, and Toolpad's.Note: I updated the pages router examples accordingly.