-
Notifications
You must be signed in to change notification settings - Fork 15
/
App.js
54 lines (45 loc) · 1.33 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
/**
* AudioVerse React Native App
* https://github.com/avorg/audioverse-mobile
* @flow
*/
import React, { PureComponent } from 'react'
import { AppState } from 'react-native'
import { Provider } from 'react-redux'
import { PersistGate } from 'redux-persist/integration/react'
import { setupPlayer, playbackUpdate } from './src/actions'
// react-navigation no redux
import AppNavigator from './src/navigators/AppNavigator'
// react-navigation with redux
// import AppNavigator from './src/navigators/ReduxNavigator'
class App extends PureComponent {
componentDidMount() {
AppState.addEventListener('change', this._handleStateChange.bind(this))
this.props.store.dispatch(setupPlayer())
}
componentWillUnmount() {
AppState.removeEventListener('change', this._handleStateChange.bind(this))
}
_handleStateChange(appState) {
if (appState == 'active') {
// update the playback information when the app is back from background mode
this.props.store.dispatch(playbackUpdate())
}
}
render() {
return (
<Provider store={this.props.store}>
<PersistGate loading={null} persistor={this.props.persistor}>
<AppNavigator />
</PersistGate>
</Provider>
)
}
}
export default function(store, persistor) {
App.defaultProps = {
store,
persistor
}
return App
}