Expo Network: isInternetReachable

Please provide the following:

  1. SDK Version: 44
  2. Platforms(Android/iOS/web/all): Android/iOS
  3. Add the appropriate “Tag” based on what Expo library you have a question on.

So, I’ve been using the library @react-native-community/netinfo to determine if the device is on the internet before making requests. But in my Sentry.io logs I am still getting errors of timeouts and cannot lookup domain names from clients randomly. These are people connected to WiFi that is probably wanting the user to login. Which is fine as my App retries. However, it proves netinfo isn’t that useful.

Then I found expo-network and getNetworkStateAsync() which is even better because it will check for isInternetReachable (Android is my main userbase). Which is great!

The problem is that what I really need is to addEventListener for when that boolean changes. Currently I have to use netinfo for the event and when that triggers I test getNetworkStateAsync().

Ideally, it would be nice if expo-network had the event and I didn’t have to bring in both libraries. Any chance Expo could add an event to expo-network when isConnected changes and/or isInternetReachable?