From 0a9c4d0be633c610b878f6287b98d08fcc5d8858 Mon Sep 17 00:00:00 2001 From: Tanner Linsley Date: Thu, 30 Jan 2025 09:44:25 -0700 Subject: [PATCH] fix(react): From location can be undefined in Tanstack Router Instrumentation (#15235) fixes #15234 Due to a big bug in TanStack Router getting fixed, this needs an optional chain to not die. --- packages/react/src/tanstackrouter.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/react/src/tanstackrouter.ts b/packages/react/src/tanstackrouter.ts index 2f5467ee1640..f0ac339fbed0 100644 --- a/packages/react/src/tanstackrouter.ts +++ b/packages/react/src/tanstackrouter.ts @@ -65,7 +65,7 @@ export function tanstackRouterBrowserTracingIntegration( // The onBeforeNavigate hook is called at the very beginning of a navigation and is only called once per navigation, even when the user is redirected castRouterInstance.subscribe('onBeforeNavigate', onBeforeNavigateArgs => { // onBeforeNavigate is called during pageloads. We can avoid creating navigation spans by comparing the states of the to and from arguments. - if (onBeforeNavigateArgs.toLocation.state === onBeforeNavigateArgs.fromLocation.state) { + if (onBeforeNavigateArgs.toLocation.state === onBeforeNavigateArgs.fromLocation?.state) { return; }