question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Listener randomly not triggered when turning on/off wifi or airplane mode

See original GitHub issue

Environment

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:closed
  • Created 2 years ago
  • Reactions:3
  • Comments:24 (18 by maintainers)

github_iconTop GitHub Comments

2reactions
cristianoccazinspcommented, Dec 18, 2021

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?

1reaction
cristianoccazinspcommented, Dec 2, 2021

@CptMaumau can you test if the changes here resolve the issue for you? https://github.com/cristianoccazinsp/react-native-netinfo/tree/android-fix

Read more comments on GitHub >

github_iconTop Results From Across the Web

Airplane mode turning on & off by itself
Select Power Management tab from the pop-up dialog box and uncheck the item Allow the computer to turn off this device to save...
Read more >
Airplane Mode Keeps Turning on and off in Windows 10 ...
After you tap or click the toggle to turn Airplane mode on or off, it can take your PC a few seconds to...
Read more >
WifiManager
Query whether or not the device supports concurrent station (STA) connections for make-before-break wifi to wifi switching. boolean, isP2pSupported().
Read more >
Can't connect with mobile data
The solution is to turn your 4G VoLTE off ( voice over LTE) In your mobile cellular settings. I dunno where is this...
Read more >
Airplane Mode: What Your Phone Can and Cannot Do
Adu being said because airplane mode turns off bluetooth while listening to music. It used to be that WIFI connections were not allowed...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found