-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.tsx
33 lines (30 loc) · 1.06 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
import React, {useEffect, useState} from 'react';
import {NavigationContainer} from '@react-navigation/native';
import {MainStack} from './src/navigation/navigation';
import {StatusBar} from 'react-native';
import SplashScreen from 'react-native-splash-screen';
import {presetBase} from './src/utils/color';
import {getDataFromStorage, LOGGEDIN_USER} from './src/utils/utils';
import ROUTE_NAME from './src/navigation/navigation-constants';
const App = () => {
const [initialRoute, setInitialRoute] = useState<string | null>(null);
useEffect(() => {
(async () => {
SplashScreen.hide();
const user = await getDataFromStorage(LOGGEDIN_USER);
console.log(user, 'user');
setInitialRoute(
user === null
? ROUTE_NAME.WELCOME_SCREEN_STACK
: ROUTE_NAME.LOGGEDIN_SCREEN_STACK,
);
})();
}, []);
return (
<NavigationContainer>
<StatusBar backgroundColor={presetBase.colors.darkBlack} />
{initialRoute && <MainStack initialRoute={initialRoute} />}
</NavigationContainer>
);
};
export default App;