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.

[RN 0.36] NetInfo.isConnected.addEventListener does not fire each time

See original GitHub issue

Hi, I am building a Network alert message using NetInfo. I test that on the simulator (ios10) by switching on/off the wifi. It seems that my listener does not fire all the time when the connection changes. May that come from how fast I toggle the wifi ?

componentWillMount() {
    NetInfo.isConnected.addEventListener(
      'change',(isConnected) => {
        console.log("isConnected......?", isConnected);
      }
    );
  }

I’ve also experienced the same issue if I set up the listener in componentDidMount.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:4
  • Comments:10 (4 by maintainers)

github_iconTop GitHub Comments

4reactions
brianinatorcommented, Dec 1, 2016

I’m also experiencing this on simulator (iOS 10). I add the event listener at the top level parent and it only registers the 1st connectivity change and then nothing after. I do not remove the listener in the event listener handler.

3reactions
hramoscommented, May 25, 2017

Closing this issue because it has been inactive for a while. If you think it should still be opened let us know why.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why does NetInfo not work for Web but works for Android ...
NetInfo on the web is missing some functionality compared to iOS and Android React Native. There is just not equivalent web APIs.
Read more >
NetInfo - React Native
addEventListener () ​ · connectionChange : Fires when the network status changes. The argument to the event handler is an object with keys:...
Read more >
NetInfo – React Native | A framework for building ... - Deco IDE
Methods # · static addEventListener(eventName: ChangeEventName, handler: Function) # · static removeEventListener(eventName: ChangeEventName, handler: Function) # ...
Read more >
react-native/CHANGELOG.md - UNPKG
This version of Android Gradle plugin enforces JDK 11 for Android builds. Do not upgrade to AGP 7.1 as it is not supported...
Read more >
React Native Cookbook Second Edition - Index of /
why all of the recipes in this book that do not require pure React Native are ... Any time there's an update to...
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