-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.tsx
66 lines (54 loc) · 1.76 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/* eslint-disable prettier/prettier */
import React, { useEffect, useLayoutEffect } from "react";
import { NavigationContainer } from "@react-navigation/native";
import { createNativeStackNavigator } from '@react-navigation/native-stack';
import AsyncStorage from '@react-native-async-storage/async-storage';
import HomeScreen from './screens/HomeScreen';
import LoginScreen from './screens/Auth/LoginScreen';
import RegisterScreen from './screens/Auth/RegisterScreen';
import MainScreen from './screens/Task/MainScreen';
import { Provider } from "react-redux";
import store from "./redux/store";
// setup redux
const Stack = createNativeStackNavigator();
const App = () => {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
// let token;
const getToken = async () => {
// token = await AsyncStorage.getAllKeys()
console.log('token', token)
const authtoken = await AsyncStorage.getItem('auth-token')
console.log('authtoken', authtoken);
await AsyncStorage.clear();
// return authtoken;
};
const token=getToken();
console.log('token',token )
// useEffect(()=>{
// })
return (
<Provider store={store}>
<NavigationContainer>
<Stack.Navigator initialRouteName={token ? 'Main' : 'Home'}>
<Stack.Screen
name="Home"
component={HomeScreen}
options={{
headerShown: false,
}}
/>
<Stack.Screen name="Register" component={RegisterScreen} />
<Stack.Screen name="Login" component={LoginScreen} />
<Stack.Screen
name="Main"
component={MainScreen}
options={{
headerShown: false,
}}
/>
</Stack.Navigator>
</NavigationContainer>
</Provider>
);
};
export default App;