-
Notifications
You must be signed in to change notification settings - Fork 1
/
App.js
71 lines (61 loc) · 1.87 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
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
67
68
69
70
71
import React, {useContext, useState} from 'react';
import {ActivityIndicator} from 'react-native';
import {NavigationContainer} from '@react-navigation/native';
import MyStack from './src/comonents/Stack/Stack';
import LoginStack from './src/comonents/Stack/LoginStack';
import AsyncStorage from '@react-native-async-storage/async-storage';
import SplashScreen from 'react-native-splash-screen';
import {useSelector} from 'react-redux';
import {AuthContext} from './src/context/Auth';
export default function App() {
const {setUser, user, token} = useContext(AuthContext);
const [save, setSave] = React.useState({});
const uid = useSelector(state => state.user);
const [loading, setLoading] = useState(true);
// const get_data = async () => {
// setLoading(true);
//ss
// I am ali
// try {
// const value = await AsyncStorage.getItem('uid');
// if (value !== 'null') {
// setSave(JSON.parse(value));
// }
// } catch (error) {
// // Error retrieving data
// }
// setLoading(false);
// };
// const get_data = async () => {
// // try {
// const value = await AsyncStorage.getItem('uid');
// // setSave(JSON.parse(value))
// if (value !== 'null' || value !== null) {
// setUser(JSON.parse(value));
// }
// // } catch (error) {
// // // Error retrieving data
// // }
// setLoading(false)
// };
React.useEffect(() => {
// get_data()
// get_data()
setTimeout(() => {
SplashScreen.hide();
}, 2000);
setLoading(false);
}, [token]);
// setUser(save === null ? uid : save)
return loading ? (
<ActivityIndicator
color={'black'}
size={'large'}
style={{flex: 1, alignItems: 'center', justifyContent: 'center'}}
/>
) : (
<NavigationContainer>
{user?.USER_ID ? <MyStack /> : <LoginStack />}
</NavigationContainer>
);
}