[RN 0.36] NetInfo.isConnected.addEventListener does not fire each time
See original GitHub issueHi, 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:
- Created 7 years ago
- Reactions:4
- Comments:10 (4 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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.
Closing this issue because it has been inactive for a while. If you think it should still be opened let us know why.