-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.js
45 lines (40 loc) · 1.15 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
import React, { useState, useEffect } from 'react';
import RootStack from './navigators/RootStack';
import AsyncStorage from '@react-native-async-storage/async-storage';
import { AgentContext } from './components/AgentContext';
import { Provider } from 'react-redux';
import store from './redux/store';
import Splash from './components/Splash';
export default function App() {
const [appReady, setAppReady] = useState(false);
const [agentData, setAgentData] = useState(null);
const checkAgentData = async () => {
await AsyncStorage.getItem('agentSessionData')
.then((agentSessionData) => {
if (agentSessionData !== null) {
setAgentData(JSON.parse(agentSessionData));
} else {
setAgentData(null);
}
})
.catch((error) => {
console.log(error);
})
.finally(() => {
setAppReady(true);
})
}
useEffect(() => {
checkAgentData();
}, []);
if (!appReady) {
return <Splash />
}
return (
<Provider store={store}>
<AgentContext.Provider value={{ agentData, setAgentData }}>
<RootStack />
</AgentContext.Provider>
</Provider>
);
}