react-native-netinfo icon indicating copy to clipboard operation
react-native-netinfo copied to clipboard

netinfo is null after making an useFetch call.

Open denotter opened this issue 4 years ago • 2 comments

Environment

System: OS: macOS 11.2.1 CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz Memory: 534.49 MB / 16.00 GB Shell: 5.8 - /bin/zsh Binaries: Node: 15.3.0 - /usr/local/bin/node Yarn: 1.22.10 - /usr/local/bin/yarn npm: 7.0.14 - /usr/local/bin/npm Watchman: 4.9.0 - /usr/local/bin/watchman Managers: CocoaPods: 1.10.1 - /usr/local/bin/pod SDKs: iOS SDK: Platforms: iOS 14.4, DriverKit 20.2, macOS 11.1, tvOS 14.3, watchOS 7.2 Android SDK: API Levels: 28, 29, 30 Build Tools: 28.0.3, 29.0.2, 30.0.3 System Images: android-30 | Google APIs Intel x86 Atom Android NDK: Not Found IDEs: Android Studio: 4.1 AI-201.8743.12.41.6953283 Xcode: 12.4/12D4e - /usr/bin/xcodebuild Languages: Java: 1.8.0_275 - /usr/bin/javac npmPackages: @react-native-community/cli: Not Found react: ~17.0.1 => 17.0.1 react-native: ~0.64.0 => 0.64.0 react-native-macos: Not Found npmGlobalPackages: react-native: Not Found

Platforms

Both

Versions

  • Android: 11
  • iOS: 14.4
  • react-native-netinfo: 6.0.0
  • react-native: 0.64
  • react: 17.0.1

Description

Reproducible Demo

When the app makes an api call, with useFetch, the netInfo returns :

{"details": null, "isConnected": null, "isInternetReachable": null, "type": "unknown"}

and afterwards returns a valid response.

I'm using netinfo in this way:

 const netInfo = useNetinfo();

Why doesn't useNetInfo knows what the state is of the current connection?

denotter avatar Mar 22 '21 14:03 denotter

have u found the solution for this? I just tried this out and am having the same issue

babyrusa avatar Apr 23 '21 17:04 babyrusa

I follow the code here and it seems to work https://github.com/react-native-netinfo/react-native-netinfo/pull/444

babyrusa avatar Apr 23 '21 17:04 babyrusa