-
Notifications
You must be signed in to change notification settings - Fork 88
/
Copy pathApp.tsx
40 lines (35 loc) · 1.15 KB
/
App.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import React from 'react';
import {NavigationContainer} from '@react-navigation/native';
import MainNavigator from './navigation/MainNavigator';
import SplashScreen from './components/SplashScreen';
import ErrorBoundary from './components/ErrorBoundary';
const AuthProvider = React.lazy(() => import('auth/AuthProvider'));
const SignInScreen = React.lazy(() => import('auth/SignInScreen'));
const App = () => {
return (
<ErrorBoundary name="AuthProvider">
<React.Suspense fallback={<SplashScreen />}>
<AuthProvider>
{(authData: {isSignout: boolean; isLoading: boolean}) => {
if (authData.isLoading) {
return <SplashScreen />;
}
if (authData.isSignout) {
return (
<React.Suspense fallback={<SplashScreen />}>
<SignInScreen />
</React.Suspense>
);
}
return (
<NavigationContainer>
<MainNavigator />
</NavigationContainer>
);
}}
</AuthProvider>
</React.Suspense>
</ErrorBoundary>
);
};
export default App;