Skip to content

Commit 5ba4f26

Browse files
fix(react): Tanstack Router integration matchRoutes signature changed
1 parent 72751da commit 5ba4f26

File tree

2 files changed

+19
-20
lines changed

2 files changed

+19
-20
lines changed

packages/react/src/tanstackrouter.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,10 @@ export function tanstackRouterBrowserTracingIntegration(
4040
const initialWindowLocation = WINDOW.location;
4141
if (instrumentPageLoad && initialWindowLocation) {
4242
const matchedRoutes = castRouterInstance.matchRoutes(
43-
initialWindowLocation.pathname,
44-
initialWindowLocation.search,
43+
{
44+
pathname: initialWindowLocation.pathname,
45+
search: castRouterInstance.options.parseSearch(initialWindowLocation.search),
46+
},
4547
{ preload: false, throwOnError: false },
4648
);
4749

@@ -66,11 +68,10 @@ export function tanstackRouterBrowserTracingIntegration(
6668
return;
6769
}
6870

69-
const onResolvedMatchedRoutes = castRouterInstance.matchRoutes(
70-
onBeforeNavigateArgs.toLocation.pathname,
71-
onBeforeNavigateArgs.toLocation.search,
72-
{ preload: false, throwOnError: false },
73-
);
71+
const onResolvedMatchedRoutes = castRouterInstance.matchRoutes(onBeforeNavigateArgs.toLocation, {
72+
preload: false,
73+
throwOnError: false,
74+
});
7475

7576
const onBeforeNavigateLastMatch = onResolvedMatchedRoutes[onResolvedMatchedRoutes.length - 1];
7677

@@ -88,11 +89,10 @@ export function tanstackRouterBrowserTracingIntegration(
8889
const unsubscribeOnResolved = castRouterInstance.subscribe('onResolved', onResolvedArgs => {
8990
unsubscribeOnResolved();
9091
if (navigationSpan) {
91-
const onResolvedMatchedRoutes = castRouterInstance.matchRoutes(
92-
onResolvedArgs.toLocation.pathname,
93-
onResolvedArgs.toLocation.search,
94-
{ preload: false, throwOnError: false },
95-
);
92+
const onResolvedMatchedRoutes = castRouterInstance.matchRoutes(onResolvedArgs.toLocation, {
93+
preload: false,
94+
throwOnError: false,
95+
});
9696

9797
const onResolvedLastMatch = onResolvedMatchedRoutes[onResolvedMatchedRoutes.length - 1];
9898

packages/react/src/vendor/tanstackrouter-types.ts

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,13 @@ SOFTWARE.
2929
export interface VendoredTanstackRouter {
3030
history: VendoredTanstackRouterHistory;
3131
state: VendoredTanstackRouterState;
32+
options: {
33+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
34+
parseSearch: (search: string) => Record<string, any>;
35+
};
3236
matchRoutes: (
33-
pathname: string,
34-
// eslint-disable-next-line @typescript-eslint/ban-types
35-
locationSearch: {},
36-
opts?: {
37-
preload?: boolean;
38-
throwOnError?: boolean;
39-
},
37+
location: VendoredTanstackRouterLocation,
38+
opts?: { preload?: boolean; throwOnError?: boolean },
4039
) => Array<VendoredTanstackRouterRouteMatch>;
4140
subscribe(
4241
eventType: 'onResolved' | 'onBeforeNavigate',
@@ -51,7 +50,7 @@ interface VendoredTanstackRouterLocation {
5150
pathname: string;
5251
// eslint-disable-next-line @typescript-eslint/ban-types
5352
search: {};
54-
state: string;
53+
state?: string;
5554
}
5655

5756
interface VendoredTanstackRouterHistory {

0 commit comments

Comments
 (0)