isInternetReachable returns false even internet is connected
See original GitHub issueEnvironment
System:
OS: macOS 12.2.1
CPU: (8) x64 Intel(R) Core(TM) i5-8279U CPU @ 2.40GHz
Memory: 30.75 MB / 8.00 GB
Shell: 5.8 - /bin/zsh
Binaries:
Node: 18.2.0 - /usr/local/bin/node
Yarn: 1.22.17 - /usr/local/bin/yarn
npm: 8.9.0 - /usr/local/bin/npm
Watchman: 2022.05.16.00 - /usr/local/bin/watchman
Managers:
CocoaPods: 1.11.3 - /usr/local/bin/pod
SDKs:
iOS SDK:
Platforms: DriverKit 21.4, iOS 15.4, macOS 12.3, tvOS 15.4, watchOS 8.5
Android SDK:
API Levels: 26, 29, 30, 31, 32
Build Tools: 28.0.3, 29.0.2, 30.0.2, 30.0.3, 31.0.0, 32.0.0, 32.1.0
System Images: android-26 | Google Play Intel x86 Atom, android-29 | Google APIs Intel x86 Atom, android-29 | Google Play Intel x86 Atom, android-30 | Google APIs Intel x86 Atom, android-30 | Google Play Intel x86 Atom, android-31 | Google APIs Intel x86 Atom_64, android-31 | Google Play Intel x86 Atom_64
Android NDK: Not Found
IDEs:
Android Studio: 2021.1 AI-211.7628.21.2111.8139111
Xcode: 13.3/13E113 - /usr/bin/xcodebuild
Languages:
Java: 11.0.11 - /usr/bin/javac
npmPackages:
@react-native-community/cli: Not Found
react: 17.0.2 => 17.0.2
react-native: ^0.66.4 => 0.66.4
react-native-macos: Not Found
npmGlobalPackages:
*react-native*: Not Found
Platforms
Android
Versions
- Android:
- iOS:
- react-native-netinfo: ^8.3.0
- react-native: ^0.66.4
- react: 17.0.2
Description
Sometimes isInternetReachable
returns false even when interent connection is active.
Actually, the issue persists when enabling Airplane mode after that isInternetReachable
returns false. but if we remove Airplane mode then WIFI connects automatically and is also able to do API requests but isInternetReachable
still returning false.
This behavior occurs sometime only. otherwise, it works perfectly.
we use useNetInfo()
hooks to identify isInternetReachable
status.
import { useNetInfo } from "@react-native-community/netinfo";
const NetworkConnection = () => {
const netInfo = useNetInfo();
const isNoConnection =
(netInfo?.type !== "unknown" &&
netInfo?.type !== "none" &&
netInfo?.isInternetReachable === false) ||
(netInfo?.type !== "unknown" && netInfo?.type === "none");
return (
<View style={CommonStyles.flexRoot}>
{isNoConnection ? (
<View style={STYLES.noInternetContainer}>
<FontedText
text="No internet connection"
fontSize={widthToDp(14)}
fontFamily={AppFonts.DMSansRegular}
color={Colors.darkRed}
/>
</View>
) : null}
</View>
);
};
Reproducible Demo
Issue Analytics
- State:
- Created a year ago
- Reactions:6
- Comments:18 (6 by maintainers)
Top Results From Across the Web
The key isInternetReachable is always returning false for a ...
I'm working on implementing network status check in a project with dynamic data and checking for internet reachability whenever an API call is ......
Read more >React Native| NetInfo to check whether has internet connection
In this tutorial, we are going to create an expo|React Native app that can detect whether has internet connection or not.
Read more >ReactNative Network Configuration | by Cbisum - Medium
When all ports are closed in the network even IsConnected property is true, isInternetReachable will be null. That means we will not be...
Read more >NetInfo - React Native
Available on all platforms. Asynchronously fetch a boolean to determine internet connectivity. NetInfo.isConnected.fetch ...
Read more >A Guide To React Native Offline Support - GeekyAnts Tech Blog
Apps need an active internet connection to communicate with their respective servers and ... isInternetReachable === false) return ( <View ...
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
Facing the same issue
me too