-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathApp.js
47 lines (37 loc) · 985 Bytes
/
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
import React from 'react';
import AsyncStorage from '@react-native-async-storage/async-storage';
import SplashScreen from 'react-native-splash-screen';
import AppNavigationContainer from './components/app_navigator';
import Context from './components/context';
class App extends React.Component {
constructor() {
super();
this.state = {
isLoggedIn: false,
setIsLoggedIn: this.setIsLoggedIn,
};
}
componentDidMount = () => {
setTimeout(() => {
this.fetchIsLoggedIn().then(() => {
SplashScreen.hide();
});
}, 1000);
}
setIsLoggedIn = (value) => {
this.setState({ isLoggedIn: value });
}
fetchIsLoggedIn = async () => {
const token = await AsyncStorage.getItem('token');
this.setState({ isLoggedIn: token ? true : false });
}
render() {
return(
<Context.Provider
value={this.state} >
<AppNavigationContainer />
</Context.Provider>
)
}
}
export default App;