Skip to content

Commit 9d875a8

Browse files
committed
Address remaining PR review comments
1 parent f8bd7b7 commit 9d875a8

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -731,7 +731,12 @@ function wrapPatchRoutesOnNavigation(
731731
(args as any).patch = (routeId: string, children: RouteObject[]) => {
732732
addRoutesToAllRoutes(children);
733733
const currentActiveRootSpan = getActiveRootSpan();
734-
if (currentActiveRootSpan && (spanToJSON(currentActiveRootSpan) as { op?: string }).op === 'navigation') {
734+
// Only update if we have a valid targetPath (patchRoutesOnNavigation can be called without path)
735+
if (
736+
targetPath &&
737+
currentActiveRootSpan &&
738+
(spanToJSON(currentActiveRootSpan) as { op?: string }).op === 'navigation'
739+
) {
735740
updateNavigationSpan(
736741
currentActiveRootSpan,
737742
{ pathname: targetPath, search: '', hash: '', state: null, key: 'default' },

packages/react/src/reactrouter-compat-utils/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export function clearNavigationContext(token: object): void {
4848
/** Gets the current (most recent) navigation context if inside a patchRoutesOnNavigation call. */
4949
export function getNavigationContext(): NavigationContext | null {
5050
const length = _navigationContextStack.length;
51-
return length > 0 ? (_navigationContextStack[length - 1] ?? null) : null;
51+
return length > 0 ? _navigationContextStack[length - 1] : null;
5252
}
5353

5454
/**

0 commit comments

Comments
 (0)