-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathApp.js
39 lines (36 loc) · 1.14 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
29
30
31
32
33
34
35
36
37
38
39
import { StyleSheet} from 'react-native'
import Home from "./components/home"
import Login from './components/login'
import { useEffect ,useState} from 'react'
import { createNativeStackNavigator } from '@react-navigation/native-stack'
import { NavigationContainer } from '@react-navigation/native'
import * as SecureStore from 'expo-secure-store';
import "expo-dev-client"
const Stack = createNativeStackNavigator();
export default function App() {
const [isLoggedIn,setIsLoggedIn] = useState()
useEffect(()=>{
async function checkIsLoggedIn(){
if(await SecureStore.getItemAsync("email")){
setIsLoggedIn(true)
}
else{
setIsLoggedIn(false)
}
}
checkIsLoggedIn()
},[])
return (
<NavigationContainer style={styles.container} independent={true}>
<Stack.Navigator initialRouteName={!isLoggedIn ? "Login" : "Home"}>
<Stack.Screen name="Home" component={Home} options={{ headerShown: false }}/>
<Stack.Screen name = "Login" component={Login}/>
</Stack.Navigator>
</NavigationContainer>
);
}
const styles = StyleSheet.create({
container: {
flex: 1
},
});