Skip to content

Commit 56cd49c

Browse files
committed
diff routes
1 parent 64c2855 commit 56cd49c

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

packages/react-router/lib/rsc/browser.tsx

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -720,14 +720,15 @@ export function RSCHydratedRouter({
720720
React.useLayoutEffect(
721721
() =>
722722
router.subscribe((newState) => {
723-
React.startTransition(() => {
724-
setState({
725-
routes: cloneRoutes(router.routes),
726-
state: newState,
723+
if (diffRoutes(router.routes, routes))
724+
React.startTransition(() => {
725+
setState({
726+
routes: cloneRoutes(router.routes),
727+
state: newState,
728+
});
727729
});
728-
});
729730
}),
730-
[router.subscribe],
731+
[router.subscribe, routes, router],
731732
);
732733

733734
const transitionEnabledRouter = React.useMemo(

0 commit comments

Comments
 (0)