Skip to content

Commit 0e679dc

Browse files
committed
Reorder to minimize diff
1 parent 6520334 commit 0e679dc

File tree

1 file changed

+22
-22
lines changed

1 file changed

+22
-22
lines changed

packages/react/src/reactrouter-compat-utils/instrumentation.tsx

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,28 @@ let _enableAsyncRouteHandlers: boolean = false;
6060

6161
const CLIENTS_WITH_INSTRUMENT_NAVIGATION = new WeakSet<Client>();
6262

63+
/**
64+
* Adds resolved routes as children to the parent route.
65+
* Prevents duplicate routes by checking if they already exist.
66+
*/
67+
export function addResolvedRoutesToParent(resolvedRoutes: RouteObject[], parentRoute: RouteObject): void {
68+
const existingChildren = parentRoute.children || [];
69+
70+
const newRoutes = resolvedRoutes.filter(
71+
newRoute =>
72+
!existingChildren.some(
73+
existing =>
74+
existing === newRoute ||
75+
(newRoute.path && existing.path === newRoute.path) ||
76+
(newRoute.id && existing.id === newRoute.id),
77+
),
78+
);
79+
80+
if (newRoutes.length > 0) {
81+
parentRoute.children = [...existingChildren, ...newRoutes];
82+
}
83+
}
84+
6385
/**
6486
* Updates a navigation span with the correct route name after lazy routes have been loaded.
6587
*/
@@ -788,25 +810,3 @@ export function createNewNavigationSpan(
788810
);
789811
}
790812
}
791-
792-
/**
793-
* Adds resolved routes as children to the parent route.
794-
* Prevents duplicate routes by checking if they already exist.
795-
*/
796-
export function addResolvedRoutesToParent(resolvedRoutes: RouteObject[], parentRoute: RouteObject): void {
797-
const existingChildren = parentRoute.children || [];
798-
799-
const newRoutes = resolvedRoutes.filter(
800-
newRoute =>
801-
!existingChildren.some(
802-
existing =>
803-
existing === newRoute ||
804-
(newRoute.path && existing.path === newRoute.path) ||
805-
(newRoute.id && existing.id === newRoute.id),
806-
),
807-
);
808-
809-
if (newRoutes.length > 0) {
810-
parentRoute.children = [...existingChildren, ...newRoutes];
811-
}
812-
}

0 commit comments

Comments
 (0)