Listener randomly not triggered when turning on/off wifi or airplane mode
See original GitHub issueEnvironment
System: OS: macOS 11.6 CPU: (8) x64 Apple M1 Memory: 17.72 MB / 16.00 GB Shell: 5.8 - /bin/zsh Binaries: Node: 12.5.0 - ~/.nvm/versions/node/v12.5.0/bin/node Yarn: 1.22.10 - ~/.nvm/versions/node/v12.5.0/bin/yarn npm: 6.9.0 - ~/.nvm/versions/node/v12.5.0/bin/npm Watchman: 2021.08.30.00 - /opt/homebrew/bin/watchman Managers: CocoaPods: 1.11.0 - /opt/homebrew/bin/pod SDKs: iOS SDK: Platforms: DriverKit 21.0.1, iOS 15.0, macOS 12.0, tvOS 15.0, watchOS 8.0 Android SDK: Not Found IDEs: Android Studio: 2020.3 AI-203.7717.56.2031.7784292 Xcode: 13.1/13A1030d - /usr/bin/xcodebuild Languages: Java: 1.8.0_144 - /usr/bin/javac Python: 2.7.16 - /usr/bin/python npmPackages: @react-native-community/cli: Not Found react: 16.13.1 => 16.13.1 react-native: 0.63.3 => 0.63.3 react-native-macos: Not Found npmGlobalPackages: react-native: Not Found
Platforms
Android
Versions
- Android: 12
- iOS:
- react-native-netinfo: 7.1.2
- react-native: 0.63.3
- react: 16.13.1
Description
When only wifi connected, the network change listener is randomly not triggered when turning on/off wifi or airplane mode.
Reproducible Demo
componentDidMount() {
this.netListenerUnsub = NetInfo.addEventListener(this.handleNetworkChange);
}
handleNetworkChange = (state: NetInfoState) => {
const { AppActions } = this.props;
console.log('network state changed', state);
AppActions.setNetwork(state.isConnected);
};
turn on/off wifi or airplane mode.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:3
- Comments:24 (18 by maintainers)
Top GitHub Comments
It’s what I described above. 7.1.6 added a change that will only work from RN 0.65 and above.
@mikehardy @HatCloud thoughts on changing https://github.com/react-native-netinfo/react-native-netinfo/pull/548 so it works for all RN versions?
@CptMaumau can you test if the changes here resolve the issue for you? https://github.com/cristianoccazinsp/react-native-netinfo/tree/android-fix