-
Notifications
You must be signed in to change notification settings - Fork 1
/
App.js
55 lines (46 loc) · 1.21 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
import React, { Component } from 'react';
import { AsyncStorage, StatusBar, View } from 'react-native';
import { Provider } from 'react-redux';
import { compose, createStore } from 'redux';
import { autoRehydrate, persistStore } from 'redux-persist';
import App from './src/app';
import { THEME } from './src/config';
import { LoadingScreen } from './src/screens';
import reducer from './src/reducer';
function configureStore() {
return new Promise((resolve) => {
const store = createStore(
reducer,
undefined,
compose(autoRehydrate()),
);
persistStore(
store,
{ storage: AsyncStorage },
() => resolve(store),
);
});
}
class Main extends Component {
constructor(props) {
super(props);
this.state = {
store: undefined,
};
}
async componentWillMount() {
this.setState({ store: await configureStore() });
}
render() {
const { store } = this.state;
return (
<View style={{ height: '100%' }}>
<StatusBar backgroundColor={THEME.PRIMARY} barStyle="light-content" />
{ !store
? <LoadingScreen />
: <Provider store={this.state.store}><App /></Provider> }
</View>
);
}
}
export default Main;