Skip to content

Commit 4c85658

Browse files
committed
Make getPath stable
1 parent a92e411 commit 4c85658

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/useLinkProps.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,13 @@ export const useLinkProps = ({
2626
}) => {
2727
const hrefPath = useMemo(() => parseRoute(href).path, [href]);
2828
const getUniversalLocation = useContext(GetUniversalLocationContext);
29-
const getPath = () => hrefPath === getUniversalLocation().raw.path;
30-
const active = useSyncExternalStore(subscribeToLocation, getPath, getPath);
3129

30+
const getPath = useCallback(
31+
() => hrefPath === getUniversalLocation().raw.path,
32+
[getUniversalLocation, hrefPath],
33+
);
34+
35+
const active = useSyncExternalStore(subscribeToLocation, getPath, getPath);
3236
const shouldReplace = replace || active;
3337
const shouldIgnoreTarget = target == null || target === "_self";
3438

0 commit comments

Comments
 (0)