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.

isInternetReachable is returning null on first attempt on ios

See original GitHub issue

Environment

System: OS: macOS 12.1 CPU: (8) x64 Intel® Core™ i5-1038NG7 CPU @ 2.00GHz Memory: 1.02 GB / 16.00 GB Shell: 5.8 - /bin/zsh Binaries: Node: 17.0.1 - /usr/local/bin/node Yarn: 1.22.17 - /usr/local/bin/yarn npm: 8.1.0 - /usr/local/bin/npm Watchman: 2021.11.08.00 - /usr/local/bin/watchman Managers: CocoaPods: 1.11.2 - /usr/local/bin/pod SDKs: iOS SDK: Platforms: DriverKit 21.2, iOS 15.2, macOS 12.1, tvOS 15.2, watchOS 8.3 Android SDK: Not Found IDEs: Android Studio: 4.0 AI-193.6911.18.40.6626763 Xcode: 13.2.1/13C100 - /usr/bin/xcodebuild Languages: Java: Not Found npmPackages: @react-native-community/cli: Not Found react: 17.0.2 => 17.0.2 react-native: 0.66.3 => 0.66.3 react-native-macos: Not Found npmGlobalPackages: react-native: Not Found

Platforms

iOS

Versions

  • iOS: 15.2.1
  • react-native-netinfo: “^7.0.0”
  • react-native: “0.66.3”
  • react: “17.0.2”

Description

This is happening on real device (iPhone 11) On my app, in an on click event, i am trying to get some data from api. Before that i am checking internet connectivity. When i’m using this

import NetInfo from "@react-native-community/netinfo";

NetInfo.fetch().then(internetState => {
  console.log(internetState);
  if (internetState.isConnected && internetState.isInternetReachable) {
    // rest of my code
  }else{
    // some warning
  }
});

on first attempt it is returning this, with isInternetReachable is returning null. LOG {“details”: {“bssid”: null, “ipAddress”: “192.168.1.2”, “isConnectionExpensive”: false, “ssid”: null, “subnet”: “255.255.255.0”}, “isConnected”: true, “isInternetReachable”: null, “type”: “wifi”}

but if i click the button again, now isInternetReachable is returning true LOG {“details”: {“bssid”: null, “ipAddress”: “192.168.1.2”, “isConnectionExpensive”: false, “ssid”: null, “subnet”: “255.255.255.0”}, “isConnected”: true, “isInternetReachable”: true, “type”: “wifi”}

Its only happening on ios. any idea guys?

Reproducible Demo

https://snack.expo.dev/@rassemdev/login-page

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:6
  • Comments:17 (7 by maintainers)

github_iconTop GitHub Comments

9reactions
mikehardycommented, Mar 12, 2022

“their” --> It is open source. There is no “they”, you are the they! All users of the library are the library developers! Welcome to the club 🤗 "waiting … " --> no need to wait! Make a PR with the fix!

1reaction
mikehardycommented, Apr 10, 2022

Definitely going to merge the refresh PR it’s just a holiday here, been busy

If there really is a platform issue I’d welcome any PR that fixes it

Read more comments on GitHub >

github_iconTop Results From Across the Web

The key isInternetReachable is always returning false for a ...
The key isInternetReachable is always returning false for a minute in iOS whenever the app comes to foreground from background in react-native.
Read more >
@react-native-community/netinfo - npm
React Native Network Info API for iOS & Android. ... isInternetReachable, boolean , null, If the internet is reachable with the currently ...
Read more >
A Guide To React Native Offline Support - GeekyAnts Tech Blog
cd ios pod install ... isInternetReachable === false) return ( <View ... Let us first try to implement caching without Redux.
Read more >
How to Handle Network Connection in Your React Native App
If you're linking with CocoaPods on iOS, be sure to use the command below: ... The useNetInfo hook returns the current network state...
Read more >
@react-native-community/netinfo | Yarn - Package Manager
React Native Network Info API for Android, iOS, macOS, Windows & Web. ... android: return netmask of first IPv4 address (#634 (f740f45), closes...
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