Skip to content

Commit ac753ca

Browse files
committed
Limit matchRoutes optimization to client side routers
1 parent 64590a2 commit ac753ca

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

.changeset/cold-days-act.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"react-router": patch
3+
---
4+
5+
Limit matchRoutes optimization to client side routers

packages/react-router/lib/hooks.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ export function useRoutesImpl(
359359
`useRoutes() may be used only in the context of a <Router> component.`
360360
);
361361

362-
let { navigator } = React.useContext(NavigationContext);
362+
let { navigator, static: isStatic } = React.useContext(NavigationContext);
363363
let { matches: parentMatches } = React.useContext(RouteContext);
364364
let routeMatch = parentMatches[parentMatches.length - 1];
365365
let parentParams = routeMatch ? routeMatch.params : {};
@@ -447,6 +447,7 @@ export function useRoutesImpl(
447447
}
448448

449449
let matches =
450+
!isStatic &&
450451
dataRouterState &&
451452
dataRouterState.matches &&
452453
dataRouterState.matches.length > 0

0 commit comments

Comments
 (0)