Skip to content

Commit b5705a0

Browse files
authored
Remove matchRoutes optimization from render pass (#13623)
1 parent 785f6f6 commit b5705a0

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

.changeset/green-emus-greet.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+
Partially revert optimization added in `6.29.0` to reduce calls to `matchRoutes` because it surfaced other issues

packages/react-router/lib/hooks.tsx

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import * as React from "react";
22
import type {
3-
AgnosticRouteMatch,
43
Blocker,
54
BlockerFunction,
65
Location,
@@ -359,7 +358,7 @@ export function useRoutesImpl(
359358
`useRoutes() may be used only in the context of a <Router> component.`
360359
);
361360

362-
let { navigator, static: isStatic } = React.useContext(NavigationContext);
361+
let { navigator } = React.useContext(NavigationContext);
363362
let { matches: parentMatches } = React.useContext(RouteContext);
364363
let routeMatch = parentMatches[parentMatches.length - 1];
365364
let parentParams = routeMatch ? routeMatch.params : {};
@@ -446,13 +445,7 @@ export function useRoutesImpl(
446445
remainingPathname = "/" + segments.slice(parentSegments.length).join("/");
447446
}
448447

449-
let matches =
450-
!isStatic &&
451-
dataRouterState &&
452-
dataRouterState.matches &&
453-
dataRouterState.matches.length > 0
454-
? (dataRouterState.matches as AgnosticRouteMatch<string, RouteObject>[])
455-
: matchRoutes(routes, { pathname: remainingPathname });
448+
let matches = matchRoutes(routes, { pathname: remainingPathname });
456449

457450
if (__DEV__) {
458451
warning(

0 commit comments

Comments
 (0)