Skip to content

Commit c3b66fa

Browse files
authored
ref(react): Use WeakSet to keep track of navigation instrumented clients (#12273)
1 parent 82f4432 commit c3b66fa

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

packages/react/src/reactrouterv6.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ let _createRoutesFromChildren: CreateRoutesFromChildren;
4747
let _matchRoutes: MatchRoutes;
4848
let _stripBasename: boolean = false;
4949

50-
const CLIENTS_WITH_INSTRUMENT_NAVIGATION: Client[] = [];
50+
const CLIENTS_WITH_INSTRUMENT_NAVIGATION = new WeakSet<Client>();
5151

5252
interface ReactRouterOptions {
5353
useEffect: UseEffect;
@@ -108,7 +108,7 @@ export function reactRouterV6BrowserTracingIntegration(
108108
}
109109

110110
if (instrumentNavigation) {
111-
CLIENTS_WITH_INSTRUMENT_NAVIGATION.push(client);
111+
CLIENTS_WITH_INSTRUMENT_NAVIGATION.add(client);
112112
}
113113
},
114114
};
@@ -222,7 +222,7 @@ function handleNavigation(
222222
const branches = Array.isArray(matches) ? matches : _matchRoutes(routes, location, basename);
223223

224224
const client = getClient();
225-
if (!client || !CLIENTS_WITH_INSTRUMENT_NAVIGATION.includes(client)) {
225+
if (!client || !CLIENTS_WITH_INSTRUMENT_NAVIGATION.has(client)) {
226226
return;
227227
}
228228

0 commit comments

Comments
 (0)