1
1
import React , { lazy , memo , Suspense , useEffect , useState } from 'react' ;
2
2
import { preload , register } from 'react-native-bundle-splitter' ;
3
- import lazyRetry from '@src/utils/lazyRetry' ;
3
+ import lazyRetry , { retryImport } from '@src/utils/lazyRetry' ;
4
4
5
- // const AuthScreens = lazy(() => lazyRetry(() => import('./AuthScreens')));
6
5
const PublicScreens = lazy ( ( ) => lazyRetry ( ( ) => import ( './PublicScreens' ) ) ) ;
7
6
7
+ const AUTH_SCREENS = 'AuthScreens' ;
8
8
const AuthScreens = register ( {
9
- name : 'AuthScreens' ,
10
- // TODO: add retry logic
11
- loader : ( ) => import ( './AuthScreens' ) ,
9
+ name : AUTH_SCREENS ,
10
+ loader : ( ) => retryImport ( ( ) => import ( './AuthScreens' ) ) ,
12
11
} ) ;
13
12
14
13
type AppNavigatorProps = {
@@ -20,10 +19,10 @@ function AppNavigator({authenticated}: AppNavigatorProps) {
20
19
const [ canNavigateToProtectedRoutes , setNavigateToProtectedRoutes ] = useState ( false ) ;
21
20
22
21
useEffect ( ( ) => {
23
- // Preload Auth Screens to be sure navigator can be mounted synchronously to avoid problems
24
- // described in https://github.com/Expensify/App/issues/44600
22
+ // Preload Auth Screens in advance to be sure that navigator can be mounted synchronously
23
+ // to avoid problems described in https://github.com/Expensify/App/issues/44600
25
24
preload ( )
26
- . component ( 'AuthScreens' )
25
+ . component ( AUTH_SCREENS )
27
26
. then ( ( ) => {
28
27
setNavigateToProtectedRoutes ( true ) ;
29
28
} ) ;
0 commit comments