-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.js
28 lines (26 loc) · 1.01 KB
/
App.js
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
import React, {useEffect, useState} from 'react'
import { createNativeStackNavigator } from '@react-navigation/native-stack';
import { NavigationContainer } from '@react-navigation/native';
import TabNabigation from './navigation/TabNavigation';
import StackNavigation from './navigation/StackNavigation';
import AsyncStorage from '@react-native-async-storage/async-storage';
export default function App() {
const [loggedIn, setLoggedIn] = useState(false)
const Stack = createNativeStackNavigator();
useEffect(async () => {
const token = await AsyncStorage.getItem('@accessToken')
if(token === null)
setLoggedIn(false)
else {
setLoggedIn(true)
}
}, [loggedIn])
return (
<NavigationContainer>
<Stack.Navigator screenOptions={{ headerShown: false }} initialRouteName={loggedIn ? "TabNavigation" : "StackNavigation"}>
<Stack.Screen name="StackNavigation" component={StackNavigation} />
<Stack.Screen name="TabNavigation" component={TabNabigation} />
</Stack.Navigator>
</NavigationContainer>
);
}