React Native version:
System:
OS: macOS High Sierra 10.13.6
CPU: (8) x64 Intel(R) Core(TM) i7-2635QM CPU @ 2.00GHz
Memory: 76.34 MB / 8.00 GB
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 10.4.1 - /usr/local/bin/node
Yarn: 1.7.0 - /usr/local/bin/yarn
npm: 6.1.0 - /usr/local/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
SDKs:
iOS SDK:
Platforms: iOS 12.1, macOS 10.14, tvOS 12.1, watchOS 5.1
Android SDK:
API Levels: 15, 21, 22, 23, 24, 26, 27, 28, 29, 8
Build Tools: 26.0.2, 27.0.0, 27.0.2, 28.0.3
System Images: android-23 | Google APIs Intel x86 Atom, android-24 | Google Play Intel x86 Atom, android-26 | Google APIs Intel x86 Atom, android-29 | Google APIs Intel x86 Atom
IDEs:
Android Studio: 3.0 AI-171.4408382
Xcode: 10.1/10B61 - /usr/bin/xcodebuild
npmPackages:
react: 16.3.1 => 16.3.1
react-native: ^0.57.8 => 0.57.8
npmGlobalPackages:
react-native-cli: 2.0.1
Steps To Reproduce
constructor(props) {
super(props);
this.state = {
appState: AppState.currentState
};
}
componentDidMount() {
AppState.addEventListener('change', this._handleAppStateChange);
}
componentWillUnmount() {
willUnmount();
AppState.removeEventListener('change', this._handleAppStateChange);
}
componentWillMount() {
WillMount();
}
_handleAppStateChange = nextAppState => {
console.log('appState',this.state.appState)
console.log('nextAppState',nextAppState)
if (
this.state.appState.match(/inactive|background/) &&
nextAppState === 'active'
) {
this.props.updateUserToken(
{
email: this.props.email
},
this.props.token
);
}
this.setState({ appState: nextAppState });
};
Describe what you expected to happen: i do nothing and appState change every single time
07-31 13:55:17.285 11867 13128 I ReactNativeJS: 'appState', 'active'
07-31 13:55:17.285 11867 13128 I ReactNativeJS: 'nextAppState', 'background'
07-31 13:55:17.381 11867 13128 I ReactNativeJS: 'appState', 'background'
07-31 13:55:17.382 11867 13128 I ReactNativeJS: 'nextAppState', 'active'
07-31 13:55:17.993 11867 13128 I ReactNativeJS: 'appState', 'active'
07-31 13:55:17.993 11867 13128 I ReactNativeJS: 'nextAppState', 'background'
07-31 13:55:18.123 11867 13128 I ReactNativeJS: 'appState', 'background'
07-31 13:55:18.123 11867 13128 I ReactNativeJS: 'nextAppState', 'active'
07-31 13:55:22.418 11867 13128 I ReactNativeJS: 'appState', 'active'
07-31 13:55:22.418 11867 13128 I ReactNativeJS: 'nextAppState', 'background'
React Native version:
System:
OS: macOS High Sierra 10.13.6
CPU: (8) x64 Intel(R) Core(TM) i7-2635QM CPU @ 2.00GHz
Memory: 76.34 MB / 8.00 GB
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 10.4.1 - /usr/local/bin/node
Yarn: 1.7.0 - /usr/local/bin/yarn
npm: 6.1.0 - /usr/local/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
SDKs:
iOS SDK:
Platforms: iOS 12.1, macOS 10.14, tvOS 12.1, watchOS 5.1
Android SDK:
API Levels: 15, 21, 22, 23, 24, 26, 27, 28, 29, 8
Build Tools: 26.0.2, 27.0.0, 27.0.2, 28.0.3
System Images: android-23 | Google APIs Intel x86 Atom, android-24 | Google Play Intel x86 Atom, android-26 | Google APIs Intel x86 Atom, android-29 | Google APIs Intel x86 Atom
IDEs:
Android Studio: 3.0 AI-171.4408382
Xcode: 10.1/10B61 - /usr/bin/xcodebuild
npmPackages:
react: 16.3.1 => 16.3.1
react-native: ^0.57.8 => 0.57.8
npmGlobalPackages:
react-native-cli: 2.0.1
Steps To Reproduce
Describe what you expected to happen: i do nothing and appState change every single time
07-31 13:55:17.285 11867 13128 I ReactNativeJS: 'appState', 'active'
07-31 13:55:17.285 11867 13128 I ReactNativeJS: 'nextAppState', 'background'
07-31 13:55:17.381 11867 13128 I ReactNativeJS: 'appState', 'background'
07-31 13:55:17.382 11867 13128 I ReactNativeJS: 'nextAppState', 'active'
07-31 13:55:17.993 11867 13128 I ReactNativeJS: 'appState', 'active'
07-31 13:55:17.993 11867 13128 I ReactNativeJS: 'nextAppState', 'background'
07-31 13:55:18.123 11867 13128 I ReactNativeJS: 'appState', 'background'
07-31 13:55:18.123 11867 13128 I ReactNativeJS: 'nextAppState', 'active'
07-31 13:55:22.418 11867 13128 I ReactNativeJS: 'appState', 'active'
07-31 13:55:22.418 11867 13128 I ReactNativeJS: 'nextAppState', 'background'