addEventListener not updated when connection change
See original GitHub issuePlatforms
Android and iOS
Versions
- react-native-netinfo: 7.1.11
- react-native: 0.63.4
- react: 17.0.1
Description
I updated the NetInfo library from 6.0.0
to the last one, but addEventListener not working if the status connection change.
I think better version 6.0.0
for the update listener.
and I go back to using 6.0.0
Issue Analytics
- State:
- Created 2 years ago
- Reactions:19
- Comments:53 (20 by maintainers)
Top Results From Across the Web
React Native - NetInfo.addEventListener not triggering when ...
I am trying to implement a offline (and yet to be added - but also a low connection) network error ...
Read more >NetworkInformation: change event - Web APIs | MDN
The change event fires when connection information changes, and the event is received by the NetworkInformation object.
Read more >NetInfo - React Native Archive
addEventListener (). NetInfo. ... connectionChange : Fires when the network status changes. ... Detect if the current active connection is metered or not....
Read more >React Native NetInfo - To Get Internet Connection Status
addEventListener (state => { console.log( 'Connection type: ' + state.type + ', Is connected?: ' + state. ... To Unsubscribe from the Network...
Read more >How to Handle Network Connection in Your React Native App
isInternetReachable — A Boolean value that determines whether or not the internet can be accessed using the current connection.
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
Platforms
Android
Versions
Hey folks, I noticed when I start the application with network and turn on airplane mode, the value of
const { isConnected } = useNetInfo()
is not updated and if I start with airplane mode turned on, and turn it off, same issue. ` In my case I cannot upgrade the react-native version cause I’m using expo, so I made a patch to solve that issue on older versions.you can install
patch-package
then go to the file
node_modules/@react-native-community/netinfo/android/src/main/java/com/reactnativecommunity/netinfo/ConnectivityReceiver.java
and remove that condition https://github.com/react-native-netinfo/react-native-netinfo/blob/6b01fee211df160d0afce70c5955681c75b24a5a/android/src/main/java/com/reactnativecommunity/netinfo/ConnectivityReceiver.java#L100and then remember to put
patch-package
command onpostinstall
script, you can check it herethen run
npx patch-package @react-native-community/netinfo
it’s working fine for me on android and didn’t create issues on ios!
…or you can update to modern react-native versions, react-native is on 0.67.3 now, I cannot imagine using 0.63 at this point, it was released so long ago