Skip to content

Commit bfb16ff

Browse files
committed
fix(router): rebuild inherited link locations during pending navigations
1 parent 22a396b commit bfb16ff

File tree

7 files changed

+1064
-41
lines changed

7 files changed

+1064
-41
lines changed

packages/react-router/src/link.tsx

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -386,13 +386,6 @@ export function useLinkProps<
386386
// href is the full path of the location, including pathname, search, and hash. Perfect for a key.
387387
(prev, next) => prev.href === next.href,
388388
)
389-
// Subscribe to resolvedLocation for relative-link resolution.
390-
// eslint-disable-next-line react-hooks/rules-of-hooks
391-
const buildLocationKey = useStore(
392-
router.stores.buildLocationReactivity,
393-
(l) => l,
394-
)
395-
396389
// eslint-disable-next-line react-hooks/rules-of-hooks
397390
const _options = React.useMemo(
398391
() => options,
@@ -410,12 +403,13 @@ export function useLinkProps<
410403
],
411404
)
412405

413-
// eslint-disable-next-line react-hooks/rules-of-hooks
414-
const next = React.useMemo(
415-
() => router.buildLocation({ ..._options } as any),
416-
// eslint-disable-next-line react-hooks/exhaustive-deps
417-
[router, _options, buildLocationKey],
418-
)
406+
const next = router.buildLocation({
407+
...(_options as any),
408+
_fromLocation:
409+
(_options as any)._fromLocation ??
410+
router.pendingBuiltLocation ??
411+
currentLocation,
412+
} as any)
419413

420414
// Use publicHref - it contains the correct href for display
421415
// When a rewrite changes the origin, publicHref is the full URL

0 commit comments

Comments
 (0)