Skip to content

Commit 8bc328c

Browse files
committed
fix: navigation ref readiness err
1 parent a14dd13 commit 8bc328c

3 files changed

Lines changed: 11 additions & 0 deletions

File tree

src/components/WideRHPContextProvider/getVisibleRHPRouteKeys.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ import {navigationRef} from '@libs/Navigation/Navigation';
88
* @param allWideRHPKeys - an array of all Wide/Super Wide RHP keys
99
*/
1010
function getVisibleWideRHPKeys(allWideRHPKeys: string[]) {
11+
if (!navigationRef.isReady()) {
12+
return [];
13+
}
14+
1115
const rootState = navigationRef.getRootState();
1216

1317
if (!rootState) {

src/libs/Navigation/Navigation.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,10 @@ const closeRHPFlow = (ref = navigationRef) => originalCloseRHPFlow(ref);
123123
* Returns the current active route.
124124
*/
125125
function getActiveRoute(): string {
126+
if (!navigationRef.isReady()) {
127+
return '';
128+
}
129+
126130
const currentRoute = navigationRef.current && navigationRef.current.getCurrentRoute();
127131
if (!currentRoute?.name) {
128132
return '';

src/libs/Navigation/helpers/isRoutePreloaded.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ import navigationRef from '@libs/Navigation/navigationRef';
33
import type {AuthScreensParamList, NavigationPartialRoute} from '@libs/Navigation/types';
44

55
export default function isRoutePreloaded(routeName: keyof AuthScreensParamList) {
6+
if (!navigationRef.isReady()) {
7+
return false;
8+
}
69
const rootState = navigationRef.getRootState() as NavigationState<AuthScreensParamList> & {preloadedRoutes: Array<NavigationPartialRoute<keyof AuthScreensParamList>>};
710
return rootState.preloadedRoutes.some((preloadedRoute) => preloadedRoute.name === routeName);
811
}

0 commit comments

Comments
 (0)