-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.js
35 lines (31 loc) · 924 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
import React, {useEffect, useState} from 'react';
import MainApp from './app/components/mainApp/mainApp';
import Provider from 'react-redux/lib/components/Provider';
import {createStore} from "redux";
import combineReducers from "./app/redux/reducers/rootReducer";
import { AppLoading } from 'expo';
import {retrieveSavedState} from "./app/services/storageService";
const store = createStore(combineReducers);
export default function App() {
const [state, setState] = useState({isReady: false});
useEffect(() => {
async function loadStateFromStorage() {
const savedState = await retrieveSavedState();
setState({
isReady: true,
savedState: savedState
});
}
loadStateFromStorage();
}, []);
if(!state.isReady) {
return (
<AppLoading />
);
}
return (
<Provider store={store}>
<MainApp savedState={state.savedState}/>
</Provider>
);
}