diff --git a/src/components/WideRHPContextProvider/getVisibleRHPRouteKeys.ts b/src/components/WideRHPContextProvider/getVisibleRHPRouteKeys.ts index de3740c3782c..7fa7c15a8052 100644 --- a/src/components/WideRHPContextProvider/getVisibleRHPRouteKeys.ts +++ b/src/components/WideRHPContextProvider/getVisibleRHPRouteKeys.ts @@ -8,6 +8,10 @@ import {navigationRef} from '@libs/Navigation/Navigation'; * @param allWideRHPKeys - an array of all Wide/Super Wide RHP keys */ function getVisibleWideRHPKeys(allWideRHPKeys: string[]) { + if (!navigationRef.isReady()) { + return []; + } + const rootState = navigationRef.getRootState(); if (!rootState) { diff --git a/src/libs/Navigation/Navigation.ts b/src/libs/Navigation/Navigation.ts index 46b717d0302f..d53578f1b991 100644 --- a/src/libs/Navigation/Navigation.ts +++ b/src/libs/Navigation/Navigation.ts @@ -123,6 +123,10 @@ const closeRHPFlow = (ref = navigationRef) => originalCloseRHPFlow(ref); * Returns the current active route. */ function getActiveRoute(): string { + if (!navigationRef.isReady()) { + return ''; + } + const currentRoute = navigationRef.current && navigationRef.current.getCurrentRoute(); if (!currentRoute?.name) { return ''; diff --git a/src/libs/Navigation/helpers/isRoutePreloaded.ts b/src/libs/Navigation/helpers/isRoutePreloaded.ts index cedd7f9c9e03..61b0cd73e05e 100644 --- a/src/libs/Navigation/helpers/isRoutePreloaded.ts +++ b/src/libs/Navigation/helpers/isRoutePreloaded.ts @@ -3,6 +3,9 @@ import navigationRef from '@libs/Navigation/navigationRef'; import type {AuthScreensParamList, NavigationPartialRoute} from '@libs/Navigation/types'; export default function isRoutePreloaded(routeName: keyof AuthScreensParamList) { + if (!navigationRef.isReady()) { + return false; + } const rootState = navigationRef.getRootState() as NavigationState & {preloadedRoutes: Array>}; return rootState.preloadedRoutes.some((preloadedRoute) => preloadedRoute.name === routeName); }