Skip to content

Commit

Permalink
Revert "fix: always ensure element before set to weakmap (#75012)"
Browse files Browse the repository at this point in the history
This reverts commit 7229934.
  • Loading branch information
lubieowoce committed Jan 20, 2025
1 parent 3f3f4bc commit b9bdd61
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions packages/next/src/client/app-dir/link.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -640,17 +640,12 @@ const Link = React.forwardRef<HTMLAnchorElement, LinkPropsReal>(
// currently mounted <Link> instances, e.g. so we can re-prefetch them after
// a revalidation or refresh.
const observeLinkVisibilityOnMount = React.useCallback(
(element: HTMLAnchorElement | SVGAElement | null) => {
(element: HTMLAnchorElement | SVGAElement) => {
if (prefetchEnabled && router !== null) {
// FIXME: element still can be null here in some cases. Require further investigation.
if (element) {
mountLinkInstance(element, href, router, appPrefetchKind)
}
mountLinkInstance(element, href, router, appPrefetchKind)
}
return () => {
if (element) {
unmountLinkInstance(element)
}
unmountLinkInstance(element)
}
},
[prefetchEnabled, href, router, appPrefetchKind]
Expand Down

0 comments on commit b9bdd61

Please sign in to comment.