-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathApp.js
42 lines (36 loc) · 1.03 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
import React from 'react';
import { Provider } from 'react-redux';
import { configureStore } from 'app/store/configureStore';
import LaunchScreen from 'app/components/LaunchScreen';
import AppHome from "app/components/AppHome";
export default class App extends React.Component {
constructor(props) {
super(props);
this.state = {
storeCreated: false,
storeRehydrated: false,
store: null
};
}
state: {
store: any
};
async componentDidMount() {
// rehydration callback (after async compatibility and persistStore)
configureStore(() => this.setState({ storeRehydrated: true }))
// creation callback (after async compatibility)
.then(store => this.setState({ store, storeCreated: true }));
}
render() {
if (!this.state.storeCreated || !this.state.storeRehydrated) {
// Show launch screen
return <LaunchScreen/>;
}
// If store is configured, we go to the app
return (
<Provider store={this.state.store}>
<AppHome/>
</Provider>
);
}
}