forked from joe-lz/QAF
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.js
More file actions
55 lines (50 loc) · 1.4 KB
/
App.js
File metadata and controls
55 lines (50 loc) · 1.4 KB
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 { AppState, StyleSheet } from 'react-native'
import codePush from "react-native-code-push"
import { connect } from 'react-redux'
import { changeLoading, changeCover } from './app/redux/actions/globalValue'
import { MainScreenNavigator } from './app/index.js'
class App extends Component<{}> {
constructor (props) {
super(props)
this.state = {
appState: ''
}
}
componentWillMount () {
}
componentDidMount() {
// AppState.addEventListener('change', this._handleAppStateChange);
}
_handleAppStateChange = (nextAppState) => {
console.log(nextAppState, 'nextAppState')
console.log(nextAppState == 'inactive' || nextAppState == 'background', 'truefalse')
if (nextAppState == 'inactive' || nextAppState == 'background') {
this.props.dispatchCHANGE_COVER(false)
} else {
this.props.dispatchCHANGE_COVER(true)
}
this.setState({appState: nextAppState});
}
render() {
return (
<MainScreenNavigator></MainScreenNavigator>
)
}
}
function mapStateToProps (state) {
return {
globalValue: state.globalValue
}
}
function mapDispatchToProps (dispatch) {
return {
dispatchCHANGE_LOADING: (data) => dispatch(changeLoading(data)),
dispatchCHANGE_COVER: (data) => dispatch(changeCover(data)),
}
}
App = codePush(App)
export default connect(
mapStateToProps,
mapDispatchToProps,
)(App)