Giter VIP home page Giter VIP logo

react-native-netinfo's Introduction

@react-native-community/netinfo

Actions Supports Android, iOS, macOS, Windows and Web MIT License Lean Core Extracted

React Native Network Info API for Android, iOS, macOS, Windows & Web. It allows you to get information on:

  • Connection type
  • Connection quality

Getting started

Install the library using either Yarn:

yarn add @react-native-community/netinfo

or npm:

npm install --save @react-native-community/netinfo

Using React Native >= 0.60

Linking the package manually is not required anymore with Autolinking.

  • iOS Platform:

    $ npx pod-install # CocoaPods on iOS needs this extra step

  • Android Platform with AndroidX:

    Modify your android/build.gradle configuration:

    buildscript {
      ext {
        buildToolsVersion = "xx.yy.zz"
        minSdkVersion = xyz
        compileSdkVersion = xyz
        targetSdkVersion = xyz
      }
    
  • macOS Platform:

    Autolinking is not yet available on macOS. See the Manual linking steps for macOS below.

Manually link the library on macOS
  1. Open your project .xcodeproj on xcode.

  2. Right click on the Libraries folder and select Add files to "yourProjectName".

  3. Add RNCNetInfo.xcodeproj (located at node_modules/@react-native-community/react-native-netinfo/macos) to your project Libraries.

  4. Go to Build Phases -> Link Binary with Libraries and add: libRNCNetInfo-macOS.a.

  • Windows Platform:

    Autolinking automatically works on RNW >= 0.63.

Minimum supported versions for windows

  • react-native-windows 0.63 or newer
  • MSVC build tools v142 (included in Visual Studio 2019) or newer
  • x86, x64, or arm64 are supported, arm (32-bit) is not supported

React Native Compatibility

To use this library you need to ensure you are using the correct version of React Native. We support react-native 0.60+ with auto-linking.

If you are using a version of React Native that is lower than 0.60 check older versions of this README for details, but no support will be provided.

Browser Compatilibity

The web implementation heavily depends on the Network Information API which is still an is an experimental technology and thus it's not supported in every browser. If this API is not available the library will safely fallback to the old onLine property and return basic connection information.

AbortController is used to cancel network requests, and may not be available on Internet Explorer, though it is available on Edge https://caniuse.com/abortcontroller

Node Compatibility

Node v16 is the minimum required node version - AbortController is only present in stable versions of node from v16 on

Migrating from the core react-native module

This module was created when the NetInfo was split out from the core of React Native. To migrate to this module you need to follow the installation instructions above and then change your imports from:

import { NetInfo } from "react-native";

to:

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

Note that the API was updated after it was extracted from NetInfo to support some new features, however, the previous API is still available and works with no updates to your code.

Usage

Global vs isolated instance

Internally this library has a network state manager class to handle all the functionality and state. This library provides two options for instantiating the class:

  1. you can use global library functions which taps into a global singleton instance of the class
  2. or you can create isolated instances of the class to tap into, each being separately configured

Global instance functions:

Subscribe to network state updates:

import { addEventListener } from "@react-native-community/netinfo";

// Subscribe
const unsubscribe = addEventListener(state => {
  console.log("Connection type", state.type);
  console.log("Is connected?", state.isConnected);
});

// Unsubscribe
unsubscribe();

Get the network state once:

import { fetch } from "@react-native-community/netinfo";

fetch().then(state => {
  console.log("Connection type", state.type);
  console.log("Is connected?", state.isConnected);
});

Get network state updates from the global instance via a react hook:

import { useNetInfo } from "@react-native-community/netinfo";

const { type, isConnected } = useNetInfo();

Isolated instance:

Use an isolated instance of the network manager:

import { useNetInfoInstance } from "@react-native-community/netinfo";

const { netInfo: { type, isConnected }, refresh } = useNetInfoInstance();

API

Types

NetInfoState

Describes the current state of the network. It is an object with these properties:

Property Type Description
type NetInfoStateType The type of the current connection.
isConnected boolean, null If there is an active network connection. Defaults to null on most platforms for unknown networks. Note: Web browsers report network type unknown for many otherwise valid networks (https://caniuse.com/netinfo), so isConnected may be true or false and represent a real connection status even for unknown network types in certain cases.
isInternetReachable boolean, null If the internet is reachable with the currently active network connection. If unknown defaults to null
isWifiEnabled boolean (Android only) Whether the device's WiFi is ON or OFF.
details The value depends on the type value. See below.

The details value depends on the type value.

type is none or unknown

details is null.

type is wifi

details has these properties:

Property Platform Type Description
isConnectionExpensive Android, iOS, macOS, Windows, Web boolean If the network connection is considered "expensive". This could be in either energy or monetary terms.
ssid Android, iOS (not tvOS), Windows string The SSID of the network. May not be present, null, or an empty string if it cannot be determined. On iOS, your app must meet at least one of the following requirements and you must set the shouldFetchWiFiSSID configuration option or no attempt will be made to fetch the SSID. On Android, you need to have the ACCESS_FINE_LOCATION permission in your AndroidManifest.xml and accepted by the user.
bssid Android, iOS (not tvOS), Windows* string The BSSID of the network. May not be present, null, or an empty string if it cannot be determined. On iOS, make sure your app meets at least one of the following requirements. On Android, you need to have the ACCESS_FINE_LOCATION permission in your AndroidManifest.xml and accepted by the user.
strength Android, Windows number An integer number from 0 to 100 for the signal strength. May not be present if the signal strength cannot be determined.
ipAddress Android, iOS, macOS, Windows string The external IP address. Can be in IPv4 or IPv6 format. May not be present if it cannot be determined.
subnet Android, iOS, macOS string The subnet mask in IPv4 format. May not be present if it cannot be determined.
frequency Android, Windows* number Network frequency. Example: For 2.4 GHz networks, the method will return 2457. May not be present if it cannot be determined.
linkSpeed Android number The link speed in Mbps.
rxLinkSpeed Android number The current receive link speed in Mbps. (Android Q / API level 29 and above)
txLinkSpeed Android number The current transmit link speed in Mbps. (Android Q / API level 29 and above)

* Requires wiFiControl capability in appxmanifest. Without it, these values will be null.

type is cellular

details has these properties:

Property Platform Type Description
isConnectionExpensive Android, iOS, macOS, Windows, Web boolean If the network connection is considered "expensive". This could be in either energy or monetary terms.
cellularGeneration Android, iOS, Windows NetInfoCellularGeneration The generation of the cell network the user is connected to. This can give an indication of speed, but no guarantees.
carrier Android, iOS string The network carrier name. May not be present or may be empty if none can be determined.
type is bluetooth, ethernet, wimax, vpn, or other

details has these properties:

Property Type Description
isConnectionExpensive boolean If the network connection is considered "expensive". This could be in either energy or monetary terms.

NetInfoStateType

Describes the current type of network connection. It is an enum with these possible values:

Value Platform Description
none Android, iOS, macOS, Windows, Web No network connection is active
unknown Android, iOS, macOS, Windows, Web The network state could not or has yet to be be determined
cellular Android, iOS, Windows, Web Active network over cellular
wifi Android, iOS, macOS, Windows, Web Active network over Wifi
bluetooth Android, Web Active network over Bluetooth
ethernet Android, macOS, Windows, Web Active network over wired ethernet
wimax Android, Web Active network over WiMax
vpn Android Active network over VPN
other Android, iOS, macOS, Windows, Web Active network over another type of network

NetInfoCellularGeneration

Describes the current generation of the cellular connection. It is an enum with these possible values:

Value Description
null Either we are not currently connected to a cellular network or type could not be determined
2g Currently connected to a 2G cellular network. Includes CDMA, EDGE, GPRS, and IDEN type connections
3g Currently connected to a 3G cellular network. Includes EHRPD, EVDO, HSPA, HSUPA, HSDPA, and UTMS type connections
4g Currently connected to a 4G cellular network. Includes HSPAP and LTE type connections
5g Currently connected to a 5G cellular network. Includes NRNSA (iOS only) and NR type connections

NetInfoConfiguration

The configuration options for the library.

Property Type Default Description
reachabilityUrl string https://clients3.google.com/generate_204 The URL to call to test if the internet is reachable. Only used on platforms which do not supply internet reachability natively or if useNativeReachability is false.
reachabilityHeaders object {} A HTTP headers object, an object literal, or an array of two-item arrays to set request's headers, to use during the reachabilityUrl URL call to test if the internet is reachable. Defaults to {}.
reachabilityMethod NetInfoMethodType HEAD The HTTP request method to use to call reachabilityUrl URL to call to test if the internet is reachable. Defaults to HEAD. GET is also available
reachabilityTest (response: Response) => boolean Promise.resolve(response.status === 204) A function which is passed the Response from calling the reachability URL. It should return true if the response indicates that the internet is reachable. Only used on platforms which do not supply internet reachability natively or if useNativeReachability is false.
reachabilityShortTimeout number 5 seconds The number of milliseconds between internet reachability checks when the internet was not previously detected. Only used on platforms which do not supply internet reachability natively or if useNativeReachability is false.
reachabilityLongTimeout number 60 seconds The number of milliseconds between internet reachability checks when the internet was previously detected. Only used on platforms which do not supply internet reachability natively or if useNativeReachability is false.
reachabilityRequestTimeout number 15 seconds The number of milliseconds that a reachability check is allowed to take before failing. Only used on platforms which do not supply internet reachability natively or if useNativeReachability is false.
reachabilityShouldRun () => boolean () => true A function which returns a boolean to determine if checkInternetReachability should be run.
shouldFetchWiFiSSID boolean false A flag indicating one of the requirements on iOS has been met to retrieve the network (B)SSID, and the native SSID retrieval APIs should be called. This has no effect on Android.
useNativeReachability boolean true A flag indicating whether or not Netinfo should use native reachability checks, if available.

Global instance methods

Please note the difference between global and isolated usage described here

configure()

Configures the library with the given configuration. You only need to supply the properties which you want to change from the default values.

Note that calling this will stop all previously added listeners from being called again. It is best to call this right when your application is started to avoid issues.

Example:

NetInfo.configure({
  reachabilityUrl: 'https://clients3.google.com/generate_204',
  reachabilityTest: async (response) => response.status === 204,
  reachabilityLongTimeout: 60 * 1000, // 60s
  reachabilityShortTimeout: 5 * 1000, // 5s
  reachabilityRequestTimeout: 15 * 1000, // 15s
  reachabilityShouldRun: () => true,
  shouldFetchWiFiSSID: true, // met iOS requirements to get SSID. Will leak memory if set to true without meeting requirements.
  useNativeReachability: false
});

addEventListener()

Subscribe to connection information. The callback is called with a parameter of type NetInfoState whenever the connection state changes. Your listener will be called with the latest information soon after you subscribe and then with any subsequent changes afterwards. You should not assume that the listener is called in the same way across devices or platforms.

Parameter Type Description
listener (state: NetInfoState) => void The listener which will be called whenever the connection state changes

Example:

// Subscribe
const unsubscribe = NetInfo.addEventListener(state => {
  console.log("Connection type", state.type);
  console.log("Is connected?", state.isConnected);
});

// Unsubscribe
unsubscribe();

useNetInfo()

A React Hook which can be used to get access to the latest state from the global instance. It returns a hook with the NetInfoState type.

Example:

import {useNetInfo} from "@react-native-community/netinfo";

const YourComponent = () => {
  const netInfo = useNetInfo();

  return (
    <View>
      <Text>Type: {netInfo.type}</Text>
      <Text>Is Connected? {netInfo.isConnected?.toString()}</Text>
    </View>
  );
};

You can optionally send configuration when setting up the hook. Note that configuration is global for the library, so you shouldn't send different configuration for different hooks. It is instead recommended that you called NetInfo.configure() once when your project starts. The hook option is only provided as a convinience.

const YourComponent = () => {
  const netInfo = useNetInfo({
    reachabilityUrl: 'https://clients3.google.com/generate_204',
    reachabilityTest: async (response) => response.status === 204,
    reachabilityLongTimeout: 60 * 1000, // 60s
    reachabilityShortTimeout: 5 * 1000, // 5s
    reachabilityRequestTimeout: 15 * 1000, // 15s
    reachabilityShouldRun: () => true,
    shouldFetchWiFiSSID: true, // met iOS requirements to get SSID
    useNativeReachability: false
  });

  // ...
};

fetch()

Returns a Promise that resolves to a NetInfoState object.

Example:

NetInfo.fetch().then(state => {
  console.log("Connection type", state.type);
  console.log("Is connected?", state.isConnected);
});

You can optionally send an interface string so the Promise resolves to a NetInfoState from the NetInfoStateType indicated in interface argument.

NetInfo.fetch("wifi").then(state => {
  console.log("SSID", state.details.ssid);
  console.log("BSSID", state.details.bssid);
  console.log("Is connected?", state.isConnected);
});

refresh()

Updates NetInfo's internal state, then returns a Promise that resolves to a NetInfoState object. This is similar to fetch(), but really only useful on platforms that do not supply internet reachability natively. For example, you can use it to immediately re-run an internet reachability test if a network request fails unexpectedly.

Example:

NetInfo.refresh().then(state => {
    console.log("Connection type", state.type);
    console.log("Is connected?", state.isConnected);
});

This will also update subscribers using addEventListener and/or useNetInfo.

Isolated instance

Please note the difference between global and isolated usage described here

useNetInfoInstance()

A React Hook which can be used to create and manage an isolated instance of a network manager class. It returns a refresh function and the current NetInfoState.

Example:

import { useNetInfoInstance } from "@react-native-community/netinfo";

const YourComponent = () => {
  const {netInfo, refresh} = useNetInfoInstance();

  return (
    <View>
      <Text>Type: {netInfo.type}</Text>
      <Text>Is Connected? {netInfo.isConnected?.toString()}</Text>
    </View>
  );
};

isPaused: You can also pause the hooks internal network checks by passing a boolean value true as the first argument.

configuration: You can optionally send configuration as the second argument when setting up the hook. Note that configuration is local to the instance managed by this hook and has no relation to the configuration passed to other functions configure() or useNetInfo();

import { useNetInfoInstance } from "@react-native-community/netinfo";

const YourComponent = () => {
  const isPaused = false;
  const config = {
    reachabilityUrl: 'https://clients3.google.com/generate_204',
    reachabilityTest: async (response) => response.status === 204,
    reachabilityLongTimeout: 60 * 1000, // 60s
    reachabilityShortTimeout: 5 * 1000, // 5s
    reachabilityRequestTimeout: 15 * 1000, // 15s
    reachabilityShouldRun: () => true,
    shouldFetchWiFiSSID: true, // met iOS requirements to get SSID
    useNativeReachability: false
  }
  
  const { netInfo } = useNetInfoInstance(isPaused, config);
  //...

Troubleshooting

Errors when building on Android

Errors while running Jest tests

If you do not have a Jest Setup file configured, you should add the following to your Jest settings and create the jest.setup.js file in project root:

setupFiles: ['<rootDir>/jest.setup.js']

You should then add the following to your Jest setup file to mock the NetInfo Native Module:

import mockRNCNetInfo from '@react-native-community/netinfo/jest/netinfo-mock.js';

jest.mock('@react-native-community/netinfo', () => mockRNCNetInfo);

Issues with the iOS simulator

There is a known issue with the iOS Simulator which causes it to not receive network change notifications correctly when the host machine disconnects and then connects to Wifi. If you are having issues with iOS then please test on an actual device before reporting any bugs.

Switching between different Wi-Fi does not send events in iOS

The SCNetworkReachability API used in iOS does not send events to the app in the background, so switching from one Wi-Fi network to another when your App was in background will not send an event and your network state will be out of sync with device state. To be sure you have up to date status when your app is in foreground again, you should re-fetch state each time when App comes to foreground, something like this:

  useEffect(() => {
    const subAppState = AppState.addEventListener("change", async (nextAppState) => {
      if (IS_IOS_DEVICE && nextAppState=='active') {
        let newNetInfo = await NativeModules.RNCNetInfo.getCurrentState('wifi');
        //your code here 
      }
    });
    const unsubNetState = NetInfo.addEventListener(state => {
        //your code here
    });
    return () => {
        if (subAppState) {
            subAppState.remove();
        }
        unsubNetState();
    };
  },[]);

Maintainers

Maintainers Emeritus

Contributing

Please see the contributing guide.

License

The library is released under the MIT license. For more information see LICENSE.

react-native-netinfo's People

Contributors

aaronechiu avatar aironefr avatar andreicoman11 avatar bestander avatar cristianoccazinsp avatar davidstritzl avatar dependabot[bot] avatar friederbluemle avatar gabelevi avatar gizomo avatar hramos avatar jeffmo avatar matt-oakes avatar mikehardy avatar nicklockwood avatar nmote avatar organom avatar rapsssito avatar sahrens avatar salakar avatar satya164 avatar sbeca avatar semantic-release-bot avatar sweggersen avatar tido64 avatar titozzz avatar tyfyakov21 avatar vjeux avatar willham12 avatar xheinrich avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

react-native-netinfo's Issues

Build problem on android

Hi,

I recently upgraded to Netinfo 2.0.6 and I'm getting the following error:

Task :@react-native-community_netinfo:compileReleaseJavaWithJavac FAILED
/Users/vsts/agent/2.150.0/work/1/s/node_modules/@react-native-community/netinfo/android/src/main/java/com/reactnativecommunity/netinfo/ConnectivityReceiver.java:14: error: package android.support.v4.net does not exist
import android.support.v4.net.ConnectivityManagerCompat;

I've tried making sure that the package is in my build.gradle but nothing is helping.

My react native version is 0.59.5.

Thanks!

Trying to subscribe to unknown event message

Environment

info
React Native Environment Info:
System:
OS: macOS 10.14.5
CPU: (8) x64 Intel(R) Core(TM) i7-5775R CPU @ 3.30GHz
Memory: 183.88 MB / 16.00 GB
Shell: 5.3 - /bin/zsh
Binaries:
Node: 10.15.3 - ~/.nvm/versions/node/v10.15.3/bin/node
Yarn: 1.13.0 - /usr/local/bin/yarn
npm: 6.4.1 - ~/.nvm/versions/node/v10.15.3/bin/npm
SDKs:
iOS SDK:
Platforms: iOS 12.2, macOS 10.14, tvOS 12.2, watchOS 5.2
Android SDK:
API Levels: 22, 23, 24, 25, 26, 27, 28
Build Tools: 23.0.1, 23.0.3, 24.0.1, 25.0.0, 25.0.2, 26.0.1, 26.0.2, 27.0.3, 28.0.0, 28.0.2, 28.0.3, 29.0.0
System Images: android-23 | Google APIs Intel x86 Atom_64, android-24 | ARM 64 v8a, android-25 | Google APIs ARM EABI v7a, android-25 | Google APIs Intel x86 Atom_64, android-25 | Google Play Intel x86 Atom, android-26 | Google APIs Intel x86 Atom, android-26 | Google Play Intel x86 Atom, android-28 | Google Play Intel x86 Atom
IDEs:
Xcode: 10.2.1/10E1001 - /usr/bin/xcodebuild
npmPackages:
react: 16.6.3 => 16.6.3
react-native: 0.59.0 => 0.59.0

Platforms

Both Android and iOS

Versions

  • Android: 9.0
  • iOS: 12.2
  • react-native-netinfo: 2.0.10
  • react-native: 0.59
  • react: 16.6.3

Description

If we use the code in readme:

const subscription = NetInfo.addEventListener(state => {
console.log("Connection type", state.type);
console.log("Is connected?", state.isConnected);
});

we got this message in logcat:

Trying to subscribe to unknown event: "function (state) {
console.log('DEBUG!!! Connection type', state.type);
console.log('DEBUG!!! Is connected?', state.isConnected);
}"

And Netinfo seems not working...
Can you help us ?

Thank you

Offline is always repoted as "unknown" instead of "none" ?

Platforms

Android

Versions

  • Android: 8.1 (Motorola G5), 9 (Pixel 2)
  • react-native-netinfo: 2.0.0
  • react-native: 0.59.4
  • react: 16.8.6

Description

Calling NetInfo.getConnectionInfo() always returns type "unknown" when wifi is turned off, and cellular data is turned off.
One would expect that "none" is returned instead. Right now, it is impossible to tell the difference between actually being offline, or not being able to tell the network status at all.

Since network info can be sometimes be unreliable (such as when called in background #64 ), being able to tell the difference between unknown and none is actually very important, since you can then implement different behaviors for each case.

[Android] Package android.support.v4.net does not exist

Environment

React Native Environment Info:
System:
OS: macOS 10.14.4
CPU: (4) x64 Intel(R) Core(TM) i5-5257U CPU @ 2.70GHz
Memory: 37.34 MB / 8.00 GB
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 8.12.0 - ~/.nvm/versions/node/v8.12.0/bin/node
Yarn: 1.9.4 - /usr/local/bin/yarn
npm: 6.4.1 - ~/.nvm/versions/node/v8.12.0/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
SDKs:
iOS SDK:
Platforms: iOS 12.2, macOS 10.14, tvOS 12.2, watchOS 5.2
IDEs:
Android Studio: 3.3 AI-182.5107.16.33.5314842
Xcode: 10.2.1/10E1001 - /usr/bin/xcodebuild
npmPackages:
react: 16.8.6 => 16.8.6
react-native: 0.59.8 => 0.59.8
npmGlobalPackages:
react-native-cli: 2.0.1
react-native-create-library: 3.1.2
react-native-git-upgrade: 0.2.7
react-native-schemes-manager: 1.0.5

Platforms

Android

Versions

  • Android:
  • iOS:
  • react-native-netinfo: 3.2.0
  • react-native: 0.59.8
  • react: 16.8.6

Description

Cannot build react-native run-android
Screen Shot 2019-05-28 at 3 00 25 PM

Reproducible Demo

  • Note:
android.useAndroidX=true
android.enableJetifier=true
classpath 'com.android.tools.build:gradle:3.3.1'
        buildToolsVersion           = "28.0.3"
        minSdkVersion               = 19
        compileSdkVersion           = 28
        targetSdkVersion            = 28
        supportLibVersion           = "28.0.0"

Android throws an error - RNCNetInfo Native module is not present

Environment

info
React Native Environment Info:
System:
OS: macOS High Sierra 10.13.6
CPU: (8) x64 Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz
Memory: 84.29 MB / 16.00 GB
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 11.0.0 - /usr/local/bin/node
Yarn: 1.10.1 - /usr/local/bin/yarn
npm: 6.4.1 - /usr/local/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
SDKs:
iOS SDK:
Platforms: iOS 12.0, macOS 10.14, tvOS 12.0, watchOS 5.0
Android SDK:
API Levels: 21, 22, 23, 24, 25, 26, 27, 28
Build Tools: 23.0.1, 23.0.2, 25.0.0, 25.0.1, 25.0.2, 25.0.3, 26.0.1, 26.0.2, 26.0.3, 27.0.3, 28.0.0, 28.0.2, 28.0.3
System Images: android-27 | Google APIs Intel x86 Atom
IDEs:
Android Studio: 3.3 AI-182.5107.16.33.5199772
Xcode: 10.0/10A255 - /usr/bin/xcodebuild
npmPackages:
react: 16.8.3 => 16.8.3
react-native: 0.59.4 => 0.59.3
npmGlobalPackages:
create-react-native-app: 1.0.0
react-native-cli: 2.0.1
react-native-create-library: 3.1.2
react-native-git-upgrade: 0.2.7

Platforms

Android

Description

Android keeps throwing an error on launch saying RNCNetInfo Native module is not present. iOS is working fine.

Reproducible Demo

See attached picture,
imageedit_3_4316371832

isConnected.fetch() returns different values on different android devices

I was trying to run the following codes:

NetInfo.isConnected.fetch().then(isConnected => {
   alert("Is connected", isConnected);
});

on OnePlus 2 and Xiaomi Redmi 4 while both devices are connected.

OnePlus2 return true and Redmi4 return false. Just a suggestion and hope we can find the solution :)

Thanks.

Error On Install Following Directions RN 59.4

Environment

React Native Environment Info:
System:
OS: macOS 10.14.4
CPU: (8) x64 Intel(R) Core(TM) i7-7920HQ CPU @ 3.10GHz
Memory: 1.17 GB / 16.00 GB
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 11.8.0 - /usr/local/bin/node
Yarn: 1.13.0 - /usr/local/bin/yarn
npm: 6.7.0 - /usr/local/bin/npm
SDKs:
iOS SDK:
Platforms: iOS 12.2, macOS 10.14, tvOS 12.2, watchOS 5.2
Android SDK:
API Levels: 24, 26, 27, 28
Build Tools: 24.0.0, 26.0.0, 28.0.3
System Images: android-27 | Android TV Intel x86 Atom, android-28 | Google APIs Intel x86 Atom, android-28 | Google Play Intel x86 Atom
IDEs:
Android Studio: 3.3 AI-182.5107.16.33.5314842
Xcode: 10.2/10E125 - /usr/bin/xcodebuild
npmPackages:
react: 16.5.0 => 16.5.0
react-native: https://github.com/expo/react-native/archive/sdk-32.0.0.tar.gz => 0.57.1
npmGlobalPackages:
react-native-cli: 2.0.1
react-native: 0.59.4

Platforms

Test on IOS only so far, actual device

Versions

Info above

Description

After following the directions, 2 steps to install I get an error running the example code that says RNCNetInfo is null. To fix this issue try these steps:, Run 'react-native link....'. I have removed the node modules and reinstalled everything. This module does not work. Very disappointing to see the NetInfo is depreciated and the replacement has problems just to run the example code.

Reproducible Demo

Just install the project using NPM per the instructions with the latest react-native version

npm install --save @react-native-community/netinfo
react-native link @react-native-community/netinfo

Update Readme

Ask your Question

can you please update the documentation?
By example
Readme says
NetInfo.fetch()
and this doesn't works at all, The Right way it's the next
NetInfo.isConnected.fetch().

annotationProcessors.json not found

Environment

Execution failed for task ':@react-native-community_netinfo:compileDebugJavaWithJavac'.

java.io.FileNotFoundException: /node_modules/@react-native-community/netinfo/android/build/intermediates/annotation_processor_list/debug/annotationProcessors.json (No such file or directory)

Platforms

Android

Versions

  • react-native-netinfo: 2.0.9
  • react-native: 0.59.5

Description

This file is not present in the relevant directory.
I tried running the assemble task inside the android folder of netinfo library. Then this file got generated inside /node_modules/@react-native-community/netinfo/android/build/intermediates/annotation_processor_list/debug/javaPreCompileDebug directory.
Then I tried pasting that file into the desired directory.
When I tried running react-native run-android command this file automatically gets removed from the directory.

Add instructions for mocking with Jest

Environment

  React Native Environment Info:
    System:
      OS: macOS 10.14.4
      CPU: (4) x64 Intel(R) Core(TM) i5-7267U CPU @ 3.10GHz
      Memory: 784.71 MB / 16.00 GB
      Shell: 5.3 - /bin/zsh
    Binaries:
      Node: 11.6.0 - ~/.nvm/versions/node/v11.6.0/bin/node
      Yarn: 1.13.0 - ~/.yarn/bin/yarn
      npm: 6.9.0 - ~/.nvm/versions/node/v11.6.0/bin/npm
      Watchman: 4.9.0 - /usr/local/bin/watchman
    SDKs:
      iOS SDK:
        Platforms: iOS 12.2, macOS 10.14, tvOS 12.2, watchOS 5.2
      Android SDK:
        API Levels: 23, 27, 28
        Build Tools: 27.0.3, 28.0.2, 28.0.3
        System Images: android-23 | Google APIs Intel x86 Atom_64, android-28 | Intel x86 Atom_64, android-28 | Google APIs Intel x86 Atom, android-28 | Google APIs Intel x86 Atom_64, android-28 | Google Play Intel x86 Atom_64
    IDEs:
      Android Studio: 3.3 AI-182.5107.16.33.5314842
      Xcode: 10.2.1/10E1001 - /usr/bin/xcodebuild
    npmPackages:
      react: 16.8.4 => 16.8.4 
      react-native: 0.59.5 => 0.59.5 
    npmGlobalPackages:
      react-native-cli: 2.0.1

Platforms

Jest

Versions

  • react-native-netinfo: 2.0.4
  • react-native: 0.59.5
  • react: 16.8.4

Description

Running a simple test in my app result in this:

 FAIL  src/__tests__/App.test.js
  โ— Test suite failed to run

    @react-native-community/netinfo: NativeModule.RNCNetInfo is null. To fix this issue try these steps:

    โ€ข Run `react-native link @react-native-community/netinfo` in the project root.
    โ€ข Rebuild and re-run the app.
    โ€ข If you are using CocoaPods on iOS, run `pod install` in the `ios` directory and then rebuild and re-run the app. You may also need to re-open Xcode to get the new pods.

    If none of these fix the issue, please open an issue on the Github repository: https://github.com/react-native-community/react-native-netinfo

      at Object.<anonymous> (node_modules/@react-native-community/netinfo/lib/commonjs/nativeInterface.js:18:9)
      at Object.<anonymous> (node_modules/@react-native-community/netinfo/lib/commonjs/index.js:14:1)

Reproducible Demo

tests/App.test.js:

import React from 'react';
import renderer from 'react-test-renderer';
import App from '../App';

describe('App tests', () => {
  test('renders correctly', () => {
    const tree = renderer.create(<App />).toJSON();
    expect(tree).toMatchSnapshot();
  });
});

run jest

Make API more flexible

Why?

  1. We require an "event name", but we actually only have a single event and likely won't add more.
  2. The effectiveType property name does not really communicate what the value means (cellular generation).
  3. The effectiveType property only makes sense when type: "cellular". Additionally, the shape of the object makes it hard to add new properties which are only applicable for one of the connection types such as "SSID" for Wifi connections. Related to issues #37 and #52.
  4. There is a mismatch between the name of NetInfo.getCurrentInfo() and NetInfo.isConnected.fetch() even though they serve the same purpose of fetching the current information once.
  5. It is not clear enough that the NetInfo.isConnected methods only say that we have an active connection, not that the internet is reachable. Related to issue #12.
  6. NetInfo.isConnectionExpensive() is only available on Android. This is useful information to know for when you want to make large API calls.

What?

// Methods
NetInfo.fetch(): Promise<NetInfoState>;
NetInfo.addEventListener(listener: (state: NetInfoState) => void): void;

// Types
type NetInfoState =
  | NetInfoUnknownState
  | NetInfoNoConnectionState
  | NetInfoCellularState
  | NetInfoWifiState
  | NetInfoBluetoothState
  | NetInfoEthernetState
  | NetInfoWimaxState;

type NetInfoConnectedDetails = {
  isConnectionExpensive: boolean,
  externalIp: string | null,
  externalIpv6: string | null,
};

type NetInfoUnknownState = {
  type: 'unknown',
  isConnected: false,
  isInternetReachable: false,
  details: null,
};

type NetInfoNoConnectionState = {
  type: 'none',
  isConnected: false,
  isInternetReachable: false,
  details: null,
};

type NetInfoCellularState = {
  type: 'cellular',
  isConnected: true,
  isInternetReachable: boolean,
  details: NetInfoConnectedDetails & {
    cellularGeneration: '2g' | '3g' | '4g' | null,
  },
};

type NetInfoWifiState = {
  type: 'wifi',
  isConnected: true,
  isInternetReachable: boolean,
  details: NetInfoConnectedDetails & {
    ssid: string | null,
  },
};

type NetInfoBluetoothState = {
  type: 'bluetooth',
  isConnected: true,
  isInternetReachable: boolean,
  details: NetInfoConnectedDetails,
};

type NetInfoEthernetState = {
  type: 'ethernet',
  isConnected: true,
  isInternetReachable: boolean,
  details: NetInfoConnectedDetails,
};

type NetInfoWimaxState = {
  type: 'wimax',
  isConnected: true,
  isInternetReachable: boolean,
  details: NetInfoConnectedDetails,
};

For the shape of the NetInfoState type:

  • Top level properties (type, isConnected, isInternetReachable) are properties which make sense across all states, including type: "none"`.
  • Properties in details are one which are only applicable for a subset of states, including those which are only applicable when connected. To tidy up the types these are defined once in the NetInfoConnectedDetails type.

Example usage:

NetInfo.addEventListener((state: NetInfoState) => {
  if (state.isConnected) {
    console.log(`Connected!`);
    console.log(`Is internet reachable: ${state.isInternetReachable}`);

    // Get the connection type and cellular generation and SSID if we have the correct types
    console.log(`Type: ${state.type}`);
    if (state.type === 'cellular') {
      console.log(`Cellular generation: ${state.details.cellularGeneration}`);
    } else if (state.type === 'wifi') {
      console.log(`Cellular generation: ${state.details.ssid}`);
    }

    // Type systems should allow this as details always has "externalIpv6" when connected, but it might be "null"
    console.log(`External IP: ${state.details.externalIpv6}`);
  } else {
    console.log('No connection');
  }
});

How does this API change solve the issues?

  1. Removes the first parameter from the NetInfo.addEventListener() method.
  2. Changes the effectiveType property to state.details.cellularGeneration.
  3. Moves the connection specific details into the state.details property. The types make it clear when these properties are available and will throw errors on both Flow and TypeScript if misused.
  4. Removes the need for the NetInfo.isConnected methods as the connected flag is now included in NetInfoState. This encourages developer to make full use of the information we fetch and is no less efficient because we always fetch all of the data anyway and transform is to a boolean in Javascript.
  5. Adds the isInternetReachable flag which makes it clearer that isConnected is not the one to use.
  6. Moving the isConnectionExpensive into state.details for all connected states makes the flag useable on both platforms and much easier to get access to.
    • Note that the implementation of this is likely to be different as Android has a way to ask the system if the connection is "metered" which has the possibility, for example, of classifying certain Wifi connections as "expensive". iOS does not have this functionality so we will likely just need to say that cellular is expensive and wifi is not. This is why the property is a boolean rather than having a fixed true or false value for each connection type.

Backward compatibility

We should not introduce such big breaking changes lightly. I believe with this API we can actually provide full backward compatibility with the current API.

  • Because we are changing the current NetInfo.getCurrentInfo() method to NetInfo.fetch() we can keep the previous one around and transform the new state shape into the current one. This was the reason for changing the method name to fetch.
  • If the user calls the NetInfo.addEventListener() method with a string as the first parameter, we can assume they want to use the current API and transform the new state shape into the current one.
  • We can keep the current NetInfo.isConnected methods is the API and simply return the isConnected boolean from the new state shape.

All of these cases can be handled in a backward compatible way and we can include Yellow Box warnings to encourage upgrading to the newer APIs.

  • Advantages:
    • Much easier upgrade path for existing developers.
    • We can gently nudge towards upgrading with yellow box warnings (likely with a "warnOnce` to avoid spamming developers).
    • The new features will only be available with the new API, so it will encourage upgrading.
  • Disadvantages:
    • We need to have some code in the library to provide backward compatibility which slightly increases the bundle size and surface areas of the library.

Discussion points

  1. Is this a good idea?
  2. Does this API look good and be something which is flexible enough to add new properties and connection types in the future as technology changes?
  3. How do we handle deprecating the current API? Do we just remove it and release a new major version or do we provide backward compatible methods which produce warnings when used?

Android: NetworkCallbackConnectivityReceiver does not report "none" status correctly

Environment

React Native Environment Info:
    System:
      OS: macOS 10.14.3
      CPU: (12) x64 Intel(R) Core(TM) i9-8950HK CPU @ 2.90GHz
      Memory: 3.03 GB / 32.00 GB
      Shell: 5.3 - /bin/zsh
    Binaries:
      Node: 10.13.0 - ~/.nvm/versions/node/v10.13.0/bin/node
      Yarn: 1.15.2 - /usr/local/bin/yarn
      npm: 6.4.1 - ~/.nvm/versions/node/v10.13.0/bin/npm
      Watchman: 4.9.0 - /usr/local/bin/watchman
    SDKs:
      iOS SDK:
        Platforms: iOS 12.1, macOS 10.14, tvOS 12.1, watchOS 5.1
      Android SDK:
        API Levels: 23, 25, 26, 27, 28
        Build Tools: 25.0.2, 27.0.3, 28.0.2, 28.0.3
        System Images: android-28 | Google APIs Intel x86 Atom, android-28 | Google Play Intel x86 Atom
    IDEs:
      Android Studio: 3.1 AI-173.4907809
      Xcode: 10.1/10B61 - /usr/bin/xcodebuild
    npmPackages:
      react: 16.8.3 => 16.8.3
      react-native: 0.59.2 => 0.59.2
    npmGlobalPackages:
      react-native-cli: 2.0.1

Platforms

Android

Versions

  • Android: 24+ (N and above)
  • iOS: NA
  • react-native-netinfo: Any
  • react-native: Any
  • react: Any

Description

The NetworkCallbackConnectivityReceiver class does not correctly handle the none case. It should set connectionType to CONNECTION_TYPE_NONE when mNetworkCapabilities is null. This will match the behaviour of iOS and older versions of Android.

Reproducible Demo

https://github.com/matt-oakes/net-info-test

@react-native-community/netinfo: NativeModule.RNCNetInfo is null... after install

Environment

React Native Environment Info:
System:
OS: macOS 10.14.4
CPU: x64 Intel(R) Core(TM) i7-7820HQ CPU @ 2.90GHz
Memory: 174.83 MB / 16.00 GB
Shell: 5.5.1 - /usr/local/bin/zsh
Binaries:
Node: 8.11.4 - ~/.nvm/versions/node/v8.11.4/bin/node
npm: 6.4.0 - ~/.nvm/versions/node/v8.11.4/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
SDKs:
iOS SDK:
Platforms: iOS 12.2, macOS 10.14, tvOS 12.2, watchOS 5.2
IDEs:
Android Studio: 3.2 AI-181.5540.7.32.5056338
Xcode: 10.2/10E125 - /usr/bin/xcodebuild
npmPackages:
react: 16.5.0 => 16.5.0
react-native: 0.57.1 => 0.57.1

Platforms

Both

Versions

  • Android: 8.0.0 && 8.0.1
  • iOS: 12.1
  • react-native-netinfo: 2.0.2 && 2.0.3
  • react-native: 0.57.1
  • react: 16.5.0

Description

I installed the latest version as well as 2.0.2, linked the package using react-native link @react-native-community/netinfo, and rebuilt the project using react-native run-ios. I got the previously reported @react-native-community/netinfo: NativeModule.RNCNetInfo is null... error.

As per @matt-oakes 's request, I am not using Cocoa Pods so there isn't a Podfile or Podlock to report, I am using react-native's link command for everything.

Screen Shot 2019-04-16 at 7 15 53 PM

Reproducible Demo

All I did was install, rebuild the project and restart the packager after importing the package in the root App.js file.

RN 0.59+ Android build error

Environment

React Native Environment Info:
System:
OS: macOS 10.14.3
CPU: (8) x64 Intel(R) Core(TM) i7-6820HQ CPU @ 2.70GHz
Memory: 78.85 MB / 16.00 GB
Shell: 5.3 - /bin/zsh
Binaries:
Node: 10.14.1 - /usr/local/bin/node
Yarn: 1.15.2 - /usr/local/bin/yarn
Watchman: 4.9.0 - /usr/local/bin/watchman
SDKs:
iOS SDK:
Platforms: iOS 12.1, macOS 10.14, tvOS 12.1, watchOS 5.1
Android SDK:
API Levels: 23, 24, 25, 26, 27, 28
Build Tools: 23.0.1, 23.0.2, 23.0.3, 25.0.0, 25.0.2, 26.0.1, 26.0.2, 26.0.3, 27.0.3, 28.0.2, 28.0.3
System Images: android-25 | Google APIs Intel x86 Atom, android-25 | Google APIs Intel x86 Atom_64, android-27 | Intel x86 Atom, android-28 | Intel x86 Atom, android-28 | Google APIs Intel x86 Atom, android-28 | Google Play Intel x86 Atom
IDEs:
Android Studio: 3.3 AI-182.5107.16.33.5314842
Xcode: 10.1/10B61 - /usr/bin/xcodebuild
npmPackages:
react: 16.8.3 => 16.8.3
react-native: 0.59.1 => 0.59.1

Platforms

Android only

Versions

  • Android: 9
  • react-native-netinfo: 1.3.0
  • react-native: 0.59.1
  • react: 16.8.3

Description

Task :@react-native-community_netinfo:compileDebugJavaWithJavac FAILED

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':@react-native-community_netinfo:compileDebugJavaWithJavac'.

Could not create service of type DefaultGeneralCompileCaches using GradleScopeCompileServices.createGeneralCompileCaches().

when could NetInfo.fetch reject?

Ask your Question

Hi. There is not any information in docs when NetInfo.fetch promise is rejected. Could you explain it in the docs?

Types not correctly declared [Typescript]

Environment

  React Native Environment Info:
    System:
      OS: macOS 10.14.3
      CPU: (8) x64 Intel(R) Core(TM) i7-6820HQ CPU @ 2.70GHz
      Memory: 48.39 MB / 16.00 GB
      Shell: 5.3 - /bin/zsh
    Binaries:
      Node: 11.0.0 - /usr/local/bin/node
      Yarn: 1.12.3 - /usr/local/bin/yarn
      npm: 6.4.1 - /usr/local/bin/npm
      Watchman: 4.9.0 - /usr/local/bin/watchman
    SDKs:
      iOS SDK:
        Platforms: iOS 12.1, macOS 10.14, tvOS 12.1, watchOS 5.1
    IDEs:
      Android Studio: 3.3 AI-182.5107.16.33.5199772
      Xcode: 10.1/10B61 - /usr/bin/xcodebuild
    npmPackages:
      react: 16.8.3 => 16.8.3
      react-native: 0.59.0-rc.3 => 0.59.0-rc.3
    npmGlobalPackages:
      react-native-cli: 2.0.1
      react-native-git-upgrade: 0.2.7
      react-native-i18n: 2.0.11

Platforms

iOS/Android/Typescript

Versions

  • react-native-netinfo: 1.2.2
  • react-native: 0.59.0-rc.3
  • react: 16.8.3

Description

When creating a project using Typescript the types file for netinfo does not declare its types correctly.

Reproducible Demo

react-native init TestNetInfo --version [email protected] --template typescript
cd TestNetInfo
Open in VSCode (other other editor supporting typescript)

Paste the following code into your App.ts file:

import React from 'react';
import { View } from 'react-native';
import NetInfo, { ConnectionInfo } from "@react-native-community/netinfo";

class App extends React.PureComponent {
  render () { return (<View/>); }
  componentDidMount() {
    NetInfo.addEventListener("connectionChange", this.connectionChanged);
  }
}

Expected

The function addEventListener should be available on the NetInfo type in the editor.

Observe

The function addEventListener is not detected as a valid type in the editor.

Build failed on ios 12.2

Environment

React Native Environment Info:
System:
OS: macOS 10.14.4
CPU: (8) x64 Intel(R) Core(TM) i7-6820HQ CPU @ 2.70GHz
Memory: 188.01 MB / 16.00 GB
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 10.13.0 - /var/folders/nl/710wyq5x15v877chfxh5hsd80000gn/T/yarn--1554154696352-0.5529216754436022/node
Yarn: 1.13.0 - /var/folders/nl/710wyq5x15v877chfxh5hsd80000gn/T/yarn--1554154696352-0.5529216754436022/yarn
npm: 6.4.1 - ~/.nvm/versions/node/v10.13.0/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
SDKs:
iOS SDK:
Platforms: iOS 12.2, macOS 10.14, tvOS 12.2, watchOS 5.2
Android SDK:
API Levels: 23, 25, 26, 27, 28
Build Tools: 26.0.0, 27.0.3, 28.0.3
System Images: android-24 | Google APIs Intel x86 Atom, android-25 | Google APIs ARM 64 v8a, android-25 | Google APIs ARM EABI v7a, android-28 | Google APIs Intel x86 Atom, android-28 | Google Play Intel x86 Atom_64
IDEs:
Android Studio: 3.3 AI-182.5107.16.33.5264788
Xcode: 10.2/10E125 - /usr/bin/xcodebuild
npmPackages:
react: 16.8.3 => 16.8.3
react-native: 0.59.0 => 0.59.0

Platforms

iOS

Versions

  • iOS: 12.2
  • react-native-netinfo: 1.4.0
  • react-native: 0.59
  • react: 16.8.3

Description

yarn react-native run-ios --device="iPhone XS" - getting build failed

image

Import NetInfo issue

Environment

  React Native Environment Info:
    System:
      OS: Linux 4.20 Arch Linux undefined
      CPU: (4) x64 Intel(R) Core(TM) i5-6500 CPU @ 3.20GHz
      Memory: 399.44 MB / 15.35 GB
      Shell: 5.0.0 - /bin/bash
    Binaries:
      Node: 10.7.0 - /usr/local/bin/node
      npm: 6.7.0 - ~/.node_modules/bin/npm
    IDEs:
      Android Studio: 3.3
    npmPackages:
      react: ^16.8.4 => 16.8.4 
      react-native: ^0.59.0 => 0.59.0 
    npmGlobalPackages:
      react-native-cli: 2.0.1
      react-native-google-signin: 0.12.0
      react-native-rename: 2.4.0

Platforms

Both

Versions

react-native-netinfo: 1.2.3
react-native: 0.59.0
react: 16.8.4
typescript: 3.3.3333

Description

When creating a project using Typescript, import NetInfo from "@react-native-community/netinfo" would throw this error:

Cannot read property 'getConnectionInfo' of undefined

ts file:

   async componentWillMount() {
        let {type} = await NetInfo.getConnectionInfo();
        if (type === "none") {
        }
    }

This is the compiled js file:

    componentWillMount() {
        return __awaiter(this, void 0, void 0, function* () {
            let { type } = yield netinfo_1.default.getConnectionInfo();
            if (type === "none") {
            }
        });
    }

To avoid this error, I have to use

const NetInfo = require("@react-native-community/netinfo");
or
import * as NetInfo from "@react-native-community/netinfo"

but either solution would lose the typing support.

Is it possible to use import * as NetInfo from "@react-native-community/netinfo while it still has the typing available?

My tsconfig:

{
  "compilerOptions": {
    "module": "commonjs",
    "target": "es6",
    "moduleResolution": "node",
    "removeComments": true,
    "allowSyntheticDefaultImports": true,
    "noImplicitAny": false,
    "experimentalDecorators": true,
    "noLib": false,
    "declaration": false,
    "emitDecoratorMetadata": true,
    "lib": ["es6", "dom"],
    "types": ["reflect-metadata"],
    "inlineSources":true,
    "skipLibCheck": true,
    "jsx": "react-native",
    "resolveJsonModule": true
  }
}

Add Wifi SSID to the connection info

Describe the Feature

NetInfo.isConnected.addEventListener only works when wifi is turned on/off. I am looking to listen to an event when wifi switches from one network to another. Can anyone have some solutions or any workarounds? Thanks in advance.

Possible Implementations

NetInfo.isConnected.addEventListener("connectionSwitch", listener)
or
NetInfo.isConnected.addEventListener("wifiConnectionSwitch", listener)

Typescript error / downlevel-iterators?

Environment

Honestly, I tried to run react-native info but it hung? That was unexpected. It only spit this bit out first:

react-native info output until it hungmike@isabela:~/work/Kullki/kscoreapp-rxp (mvp3-dev *) % react-native info info React Native Environment Info: System: OS: Linux 5.1 Ubuntu 19.04 (Disco Dingo) CPU: (12) x64 Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz Memory: 685.18 MB / 31.13 GB Shell: 5.0.3 - /bin/bash Binaries: Node: 12.2.0 - ~/.nvm/versions/node/v12.2.0/bin/node Yarn: 1.16.0 - ~/.nvm/versions/node/v12.2.0/bin/yarn npm: 6.9.0 - ~/.nvm/versions/node/v12.2.0/bin/npm SDKs: Android SDK: API Levels: 15, 16, 17, 18, 19, 21, 22, 23, 24, 25, 26, 27, 28 Build Tools: 23.0.1, 24.0.0, 24.0.2, 25.0.0, 25.0.1, 25.0.2, 26.0.0, 26.0.3, 27.0.3, 28.0.0, 28.0.1, 28.0.2, 28.0.3, 29.0.0 System Images: android-15 | Intel x86 Atom, android-15 | Google APIs Intel x86 Atom, android-16 | ARM EABI v7a, android-16 | Intel x86 Atom, android-16 | Google APIs Intel x86 Atom, android-17 | Intel x86 Atom, android-17 | Google APIs Intel x86 Atom, android-18 | Intel x86 Atom, android-18 | Google APIs Intel x86 Atom, android-19 | Intel x86 Atom, android-19 | Google APIs Intel x86 Atom, android-21 | Intel x86 Atom, android-21 | Google APIs Intel x86 Atom, android-22 | ARM EABI v7a, android-22 | Intel x86 Atom, android-22 | Google APIs ARM EABI v7a, android-23 | Android TV Intel x86 Atom, android-23 | Intel x86 Atom, android-23 | Google APIs ARM EABI v7a, android-23 | Google APIs Intel x86 Atom, android-24 | ARM 64 v8a, android-24 | ARM EABI v7a, android-24 | Intel x86 Atom, android-24 | Google APIs Intel x86 Atom, android-25 | Google APIs ARM 64 v8a, android-25 | Google APIs ARM EABI v7a, android-25 | Google APIs Intel x86 Atom, android-26 | Google APIs Intel x86 Atom, android-27 | Google APIs Intel x86 Atom, android-28 | Google APIs Intel x86 Atom, android-Q | Google Play Intel x86 Atom_64, chromeos-67 | Chrome OS 67 npmPackages: react: ^16.8.6 => 16.8.6 react-native: ^0.59.8 => 0.59.8 npmGlobalPackages: react-native-cli: 2.0.1

Platforms

both - but really, typescript 3.4.5 with this tsconfig:

{
  "compilerOptions": {
    "declaration": false,
    "noResolve": false,
    "jsx": "react",
    "reactNamespace": "RX",
    "lib": ["dom", "es5", "scripthost", "es2015"],
    "module": "commonjs",
    "target": "es5",
    "experimentalDecorators": true,
    "sourceMap": true,
    "skipLibCheck": true,
    "noImplicitAny": true,
    "noImplicitReturns": true,
    "outDir": "./dist/",
    "strict": true
  },
  "exclude": ["node_modules"],
  "include": ["./src/**/*"]
}

Versions

  • Android: N/A
  • iOS: N/A
  • react-native-netinfo: 3.1.0
  • react-native: 0.59.8
  • react: 16.8.6

Description

I run tsc and get this, with the above tsconfig.json:

[12:39:59 AM] Starting compilation in watch mode...

node_modules/@react-native-community/netinfo/src/internal/deprecatedSubscriptions.ts:23:23 - error TS2569: Type 'Set<ChangeHandler>' is not an array type or a string type. Use compiler option '--downlevelIteration' to allow iterating of iterators.

23   for (let handler of _subscriptions) {
                         ~~~~~~~~~~~~~~

node_modules/@react-native-community/netinfo/src/internal/subscriptions.ts:23:23 - error TS2569: Type 'Set<NetInfoChangeHandler>' is not an array type or a string type. Use compiler option '--downlevelIteration' to allow iterating of iterators.

23   for (let handler of _subscriptions) {
                         ~~~~~~~~~~~~~~

[12:40:06 AM] Found 2 errors. Watching for file changes.

Reproducible Demo

If you paste my tsconfig.json over the project's one in the root, then run npm run validate:typescript you will see it

This looked like interesting related reading: https://mariusschulz.com/blog/typescript-2-3-downlevel-iteration-for-es3-es5

I suppose I could move up to es6 as my target but it would be nice for safety's sake in a ReactXP project (that touches the web) to stay on ES5 just in case. Maybe there's an easy refactor to remove the need for this style iteration?

Or at the least you should warn that the typescript requires either ES6 or downlevel-iterators, but then you might take note of the tslib/importhelpers note in the linked article

Android resolver : Indeed, none of these files exist: netinfo/src/index.ts

Environment

Environment:
OS: macOS 10.14.4
Node: 10.15.3
Yarn: Not Found
npm: 6.4.1
Watchman: Not Found
Xcode: Xcode 10.2.1 Build version 10E1001
Android Studio: 3.4 AI-183.5429.30.34.5452501

Packages: (wanted => installed)
react: ^16.3.1 => 16.3.1
react-native: ^0.55.4 => 0.55.4

Platforms

Android

Description

Resolver doesn't find the module. Still, the package is correctly installed, linked, and the file exist.

I tried to reset-cache, rm -rf node_modules and npm i, still can't resolve this module.

bundling failed: Error: 
While trying to resolve module `@react-native-community/netinfo` from file `xxx/app/middleware/network.js`, 
the package `xxx/node_modules/@react-native-community/netinfo/package.json` was successfully found. 
However, this package itself specifies a `main` module field that could not be resolved (`xxx/node_modules/@react-native-community/netinfo/src/index.ts`. 

Indeed, none of these files exist:

  * `xxx/node_modules/@react-native-community/netinfo/src/index.ts(.native||.android.js|.native.js|.js|.android.json|.native.json|.json)

Build on android issues

Environment

$ react-native info
info
React Native Environment Info:
System:
OS: Windows 10
CPU: (4) x64 Intel(R) Core(TM) i7-7660U CPU @ 2.50GHz
Memory: 921.76 MB / 7.93 GB
Binaries:
npm: 6.9.0 - C:\Program Files\nodejs\npm.CMD
IDEs:
Android Studio: Version 3.4.0.0 AI-183.5429.30.34.5452501

Platforms

Android

Versions

  • Android: 2.0.6
  • iOS: 2.0.6
  • react-native-netinfo:
  • react-native: 0.59.5
  • react: 16.8.4

Description

When compiling the android binary I get this error:

Task :@react-native-community_netinfo:compileReleaseJavaWithJavac FAILED
/Users/vsts/agent/2.150.0/work/1/s/node_modules/@react-native-community/netinfo/android/src/main/java/com/reactnativecommunity/netinfo/ConnectivityReceiver.java:14: error: package android.support.v4.net does not exist
import android.support.v4.net.ConnectivityManagerCompat;
^
/Users/vsts/agent/2.150.0/work/1/s/node_modules/@react-native-community/netinfo/android/src/main/java/com/reactnativecommunity/netinfo/ConnectivityReceiver.java:78: error: cannot find symbol
promise.resolve(ConnectivityManagerCompat.isActiveNetworkMetered(getConnectivityManager()));
^
symbol: variable ConnectivityManagerCompat
location: class ConnectivityReceiver
2 errors

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':@react-native-community_netinfo:compileReleaseJavaWithJavac'.

Compilation failed; see the compiler error output for details.

Reproducible Demo

Code matches the sample on the github repo

I have tried putting the old android.support.v4 libraries into my build.gradle. I had to upgrade to androidx for support of @react-native-communiy/slider so I've tried using that to do legacy libraries too but they all fail.

Podfile is broken in 2.0.1

Environment

React Native Environment Info:
System:
OS: macOS 10.14.4
CPU: (8) x64 Intel(R) Core(TM) i7-7920HQ CPU @ 3.10GHz
Memory: 127.13 MB / 16.00 GB
Shell: 5.3 - /bin/zsh
Binaries:
Node: 11.12.0 - /usr/local/bin/node
Yarn: 1.15.2 - /usr/local/bin/yarn
npm: 6.7.0 - /usr/local/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
SDKs:
iOS SDK:
Platforms: iOS 12.1, macOS 10.14, tvOS 12.1, watchOS 5.1
IDEs:
Android Studio: 3.3 AI-182.5107.16.33.5314842
Xcode: 10.1/10B61 - /usr/bin/xcodebuild
npmPackages:
react: 16.8.3 => 16.8.3
react-native: 0.59.4 => 0.59.4
npmGlobalPackages:
create-react-native-app: 1.0.0
react-native-cli: 2.0.1
react-native-git-upgrade: 0.2.7

Platforms

iOS

Versions

  • react-native-netinfo: 2.0.1
  • react-native: 0.59.4
  • react: 16.8.3

Description

After upgrading from 2.0.0 to 2.0.1 pod init returns in this error. [!] No podspec found for 'react-native-netinfo' in '../node_modules/@react-native-community/netinfo' before the update everything is working fine. There's no new instruction for linking or a warning in the release.

NetInfo.getConnectionInfo() return unknown for android

Environment

  React Native Environment Info:
    System:
      OS: macOS 10.14.4
      CPU: (12) x64 Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz
      Memory: 86.61 MB / 16.00 GB
      Shell: 3.2.57 - /bin/bash
    Binaries:
      Node: 11.3.0 - /usr/local/bin/node
      Yarn: 1.12.3 - /usr/local/bin/yarn
      Watchman: 4.9.0 - /usr/local/bin/watchman
    SDKs:
      iOS SDK:
        Platforms: iOS 12.1, macOS 10.14, tvOS 12.1, watchOS 5.1
      Android SDK:
        API Levels: 25, 26, 27, 28
        Build Tools: 26.0.2, 27.0.3, 28.0.3
        System Images: android-27 | Intel x86 Atom_64, android-28 | Google APIs Intel x86 Atom
    IDEs:
      Android Studio: 3.2 AI-181.5540.7.32.5056338
      Xcode: 10.1/10B61 - /usr/bin/xcodebuild
    npmPackages:
      react: 16.6.3 => 16.6.3 
      react-native: 0.58.3 => 0.58.3 

Platforms

Android

Versions

  • Android: 7.0
  • iOS:
  • react-native-netinfo: ^2.0.0
  • react-native: 0.58.3
  • react: 16.6.3

Description

It's the same issue which is described here.

Reproducible Demo

import React, { Component } from 'react'
import {
    View,
    Text
} from 'react-native'

import { connect } from 'src/store'
import NetInfo from "@react-native-community/netinfo";

class InternetConnection extends Component {
    listener = null
    state = {
        online: false
    }

    componentDidMount () {
        let me = this

        me.listener = NetInfo.isConnected.addEventListener('connectionChange', me.onConnectionChange.bind(me))
    }

    componentWillUnmount () {
        let me = this

        if (me.listener) {
            me.listener.remove()
        }
    }

    onConnectionChange ({ info, effectiveType }) {
        let me = this

        if (!info || info === 'none' || info === 'unknown') {
            me.setState({ online: false })
        } else {
            me.setState({ online: true })
        }

        console.log(info, effectiveType)
    }

    render() {
        let { online } = this.state

        if (online) {
            return null
        }

        return (
            <View style={{ backgroundColor: 'red', padding: 5 }}>
                <Text style={{ textAlign: 'center', color: '#fff' }}>
                    Offline
                </Text>
            </View>
        )
    }

}

export default connect(InternetConnection)

Automatic linking fails on Android

Environment

  React Native Environment Info:
    System:
      OS: macOS 10.14.3
      CPU: (8) x64 Intel(R) Core(TM) i7-6920HQ CPU @ 2.90GHz
      Memory: 225.40 MB / 16.00 GB
      Shell: 2.7.1 - /usr/local/bin/fish
    Binaries:
      Node: 10.15.0 - ~/.nvm/versions/node/v10.15.0/bin/node
      Yarn: 1.12.3 - /usr/local/bin/yarn
      npm: 6.4.1 - ~/.nvm/versions/node/v10.15.0/bin/npm
      Watchman: 4.9.0 - /usr/local/bin/watchman
    SDKs:
      iOS SDK:
        Platforms: iOS 12.2, macOS 10.14, tvOS 12.2, watchOS 5.2
      Android SDK:
        API Levels: 24, 25, 26, 27, 28
        Build Tools: 27.0.3, 28.0.2, 28.0.3
        System Images: android-28 | Google APIs Intel x86 Atom, android-28 | Google Play Intel x86 Atom
    IDEs:
      Android Studio: 3.2 AI-181.5540.7.32.5056338
      Xcode: 10.2/10E125 - /usr/bin/xcodebuild
    npmPackages:
      react: 16.8.3 => 16.8.3
      react-native: 0.59.1 => 0.59.1

Platforms

Android

Versions

  • Android: 2.0.0

Description

react-native link @react-native-community/netinfo command is not linking the library properly.

To fix this issue one must manually add the following

android/app/build.gradle:

dependencies {
...
implementation project(':@react-native-community_netinfo')
}

android/app/src/main/java/.../MainApplication.java:

protected List<ReactPackage> getPackages() {
...
new NetInfoPackage()
}

We are using react-native-navigation that causes the MainApplication.java to be a slightly different than it is in React Native's project template.

Reproducible Demo

  • Install package from NPM
  • Run react-native link for the package

[ci] android tests

Just throwing up an issue to track some issues with Android CI flakiness;


Potential workaround: I think this is just down to lack of host gpu support on Circle CI & gpu emulation being slow - could increase the timeout


Potential fix: Add a Jest afterAll() global and a await device.terminateApp(); or process.exit(0)


I can take a look at these sometime next week; unless someone beats me too it ๐Ÿ™ƒ

Result from background calls (headless/fetch) always unknown?

Following this issue: #32

Calls to await NetInfo.getConnectionInfo(); always return type "unknown" when called from a headless or background task (such as when using react-native-background-fetch).

Is there a way to get an uncached version of the network info? This is critical to only perform background requests when the user is on wifi.

NetInfo.getConnectionInfo() return unknown for android

I am using the following code to get the connection info but it return unknown for android:

componentDidMount() { NetInfo.getConnectionInfo().then(connectionInfo => { console.log("Connection type", connectionInfo.type); console.log("Connection effective type", connectionInfo.effectiveType); }); }

React Native Version: 0.59.0

Fix Android Warnings

Platforms

Android

Description

Android has multiple Java and Lint warnings which, depending on project configuration, could cause build errors. These should all be fixed or suppressed.

Gradle 5.+ and name issue

Platforms

Android

Description

When trying to use this plugin with Gradle 5.0 (which should come soon to RN facebook/react-native#23324), I am getting these error :


* What went wrong:
A problem occurred configuring project ':@react-native-community/netinfo'.
> The project name '@react-native-community/netinfo' must not contain any of the following characters: [/, \, :, <, >, ", ?, *, |]. Set the 'rootProject.name' or adjust the 'include' statement (see https://docs.gradle.org/5.2/dsl/org.gradle.api.initialization.Settings.html#org.gradle.api.initialization.Settings:include(java.lang.String[]) for more details).

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

I think it is because Gradle 5.+ does not accept anymore that kind of name : https://docs.gradle.org/current/userguide/upgrading_version_4.html

Thanking you in advance

Connection with a vpn at android is not recognized

Platforms

Android

Versions

  • Android: 9 (Samsung Galaxy S8)
  • react-native-netinfo: 2.0.9
  • react-native: 0.59.0

Description

Calling NetInfo.getConnectionInfo() returns type "unknown", if a vpn is activated and the device have a connection with wifi/cellular.
The deprecated intern React Native Package have the correct return of "wifi" by calling getConnectionInfo().
Also calling NetInfo.isConnected() return "false".

NativeModule.RNCNetInfo is null

Environment

React Native Environment Info:
    System:
      OS: macOS 10.14.3
      CPU: (4) x64 Intel(R) Core(TM) i5-7360U CPU @ 2.30GHz
      Memory: 350.61 MB / 16.00 GB
      Shell: 5.3 - /bin/zsh
    Binaries:
      Node: 11.12.0 - /usr/local/bin/node
      Yarn: 1.12.3 - /usr/local/bin/yarn
      npm: 6.7.0 - /usr/local/bin/npm
      Watchman: 4.9.0 - /usr/local/bin/watchman
    SDKs:
      iOS SDK:
        Platforms: iOS 12.1, macOS 10.14, tvOS 12.1, watchOS 5.1
      Android SDK:
        API Levels: 19, 21, 23, 25, 26, 27, 28
        Build Tools: 23.0.1, 25.0.2, 26.0.3, 27.0.3, 28.0.3
        System Images: android-19 | Google APIs ARM EABI v7a, android-21 | Google APIs ARM EABI v7a, android-25 | Google APIs Intel x86 Atom, android-26 | Google APIs Intel x86 Atom, android-26 | Google APIs Intel x86 Atom_64, android-27 | Google Play Intel x86 Atom
    IDEs:
      Android Studio: 2.3 AI-162.4069837
      Xcode: 10.1/10B61 - /usr/bin/xcodebuild
    npmPackages:
      react: 16.8.3 => 16.8.3 
      react-native: 0.59.4 => 0.59.4 
    npmGlobalPackages:
      react-native-cli: 2.0.1

Platforms

Versions

  • Android: 7.1.1
  • iOS: 12.1
  • react-native-netinfo: 2.0.1
  • react-native: 0.59.4
  • react: 16.8.3

Description

Just used yarn to add the package, and I am getting this error. I have followed the instructions suggested in the message. I am not using CocoaPods.
Screen Shot 2019-04-14 at 4 34 22 PM

Reproducible Demo

Simply importing the library as described in the README documentation produces the error.

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

No default export found in module

No default export found in module

Hi all, ever since we migrated from the original ReactNative library to this one we've been having two issues, one with eslint error (which can be ignored) that complains about no default export being found and more importantly with Jest:

.../node_modules/@react-native-community/netinfo/js/index.js:11
    import {Platform} from 'react-native';
           ^

which seems to be similar.

Judging by google result and the fact that no one else seems to be having this issue I think we're doing something wrong but after a few days of trying I thought it's best to ask here.

correct me if I'm wrong but judging by the source code looks like this library is using es5 style module export which seems to be related to the errors we're getting?

Any help or ideas would be much appreciated :) Thanks!

Build Failed in Android

Environment

Environment:
OS: Windows 10
Node: 10.15.3
Yarn: Not Found
npm: 3.10.10
Watchman: Not Found
Xcode: N/A
Android Studio: Version 3.3.0.0 AI-182.5107.16.33.5314842

Packages: (wanted => installed)
react: 16.2.0 => 16.2.0
react-native: 0.52.0 => 0.52.0

Issue

Loading dependency graph, done.
error: bundling failed: SyntaxError in D:\github\markit\node_modules@react-native-community\netinfo\js\index.js: D:/github/markit/node_modules/@react-native-community/netinfo/js/index.js: Unexpected token (42:46)
40 | type IsConnectedHandler = (isConnected: boolean) => void;
41 |

42 | const _subscriptions = new Set();
| ^
43 | const _isConnectedSubscriptions = new Map();
44 |
45 | let _latestNetInfo = null;
DELTA [android, dev] ./index.js โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘ 62.9% (613/773), failed.

Platforms

On Android

Description

I am getting this error on build my android app, help needed.

getConnectionInfo & isConnected returns different values on different android devices

Environment

info
React Native Environment Info:
System:
OS: macOS 10.14.3
CPU: (4) x64 Intel(R) Core(TM) i5-5257U CPU @ 2.70GHz
Memory: 17.01 MB / 16.00 GB
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 8.9.4 - /usr/local/bin/node
Yarn: 1.6.0 - /usr/local/bin/yarn
npm: 6.4.1 - /usr/local/bin/npm
Watchman: 4.4.0 - /usr/local/bin/watchman
SDKs:
iOS SDK:
Platforms: iOS 12.1, macOS 10.14, tvOS 12.1, watchOS 5.1
Android SDK:
API Levels: 23, 25, 26, 27, 28
Build Tools: 23.0.1, 23.0.2, 23.0.3, 25.0.0, 25.0.2, 26.0.1, 26.0.2, 27.0.0, 27.0.3, 28.0.2, 28.0.3
System Images: android-23 | Intel x86 Atom_64, android-23 | Google APIs Intel x86 Atom_64, android-28 | Google APIs Intel x86 Atom
IDEs:
Android Studio: 3.0 AI-171.4408382
Xcode: 10.1/10B61 - /usr/bin/xcodebuild
npmPackages:
react: ^16.8.3 => 16.8.4
react-native: ^0.59.4 => 0.59.4
npmGlobalPackages:
create-react-native-app: 1.0.0
react-native-cli: 2.0.1
react-native-git-upgrade: 0.2.7

Platforms

Android on different brands

Versions

  • Android: OnePlus2 Android version 6.0, Redmi Note 4 Android version 7.0
  • react-native-netinfo: ^1.3.0
  • react-native: ^0.59.4
  • react: ^16.8.3

Description

I was trying to run the following codes:

NetInfo.isConnected.fetch().then(isConnected => {
   alert("Is connected", isConnected);
});

on OnePlus 2 and Xiaomi Redmi 4 while both devices are connected.

OnePlus2 return true and Redmi4 return false. With suggestion from @matt-oakes , I ran the following codes on both devices with and without internet connection.

NetInfo.getConnectionInfo().then(connectionInfo => {
  console.log("Connection type", connectionInfo.type);
  console.log("Connection effective type", connectionInfo.effectiveType);
});

Results are as following:

Redmi Note 4
Either when connected or not connected,
Connection type - unknown
Connection effective type - unknown

OnePlus2
When connected,
Connection type - wifi
Connection effective type - unknown

When not connected,
Connection type - none
Connection effective type - unknown

Reproducible Demo

I just created a simple project and run the codes on both devices.

getConnectionInfo returns wrong info if network state changes while app is "sleeping" in background

Environment

React Native Environment Info:
System:
OS: Windows 10
CPU: (4) x64 Intel(R) Core(TM) i5-3230M CPU @ 2.60GHz
Memory: 6.47 GB / 15.95 GB
Binaries:
Yarn: 1.13.0 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
npm: 6.4.1 - C:\Program Files\nodejs\npm.CMD
IDEs:
Android Studio: Version 3.3.0.0 AI-182.5107.16.33.5314842

Platforms

I'm experiencing the issue on both iOS and Android.

Versions

  • Android: 7.1.2
  • iOS: 12.1.4
  • react-native-netinfo: 1.3.0
  • react-native: 0.59.1
  • react: 16.8.3

Description

If the network state changes while the app is in background, NetInfo.getConnectionInfo() returns the older state until the state changes again with the app in foreground.
A similar issue was opened on 4 Oct 2018 on the react-native repo: facebook/react-native#21476.
I don't know if it's a regression or not.

Reproducible Demo

I call the function when the instrested component mounts:

static getDeviceConnectionInfo = async () => {
    const info = await NetInfo.getConnectionInfo();
    Reactotron.log('G O T   N E T   I N F O', info);
    return info;
}

It returns the correct state. If I disable the WiFi (for example) and re-mount my component (it's a modal that I mount/unmount) the state I get is correct and updated (type === unknown).

Now i put the app in background and I re-enable the WiFi. Then I resume the app and open the modal again. The state returned is still type === unknown.

The state I get doesn't update until I make another network change with the app in foreground.

CocoaPods crashes (with the stupid React dependency in podfile)

Environment

info
React Native Environment Info:
System:
OS: macOS 10.14.3
CPU: x64 Intel(R) Core(TM) i7-6567U CPU @ 3.30GHz
Memory: 261.48 MB / 16.00 GB
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 8.15.1 - /usr/local/bin/node
Yarn: 1.15.2 - /usr/local/bin/yarn
npm: 6.7.0 - /usr/local/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
SDKs:
iOS SDK:
Platforms: iOS 12.2, macOS 10.14, tvOS 12.2, watchOS 5.2
Android SDK:
Build Tools: 21.1.1, 21.1.2, 22.0.0, 22.0.1, 23.0.1, 23.0.2, 23.0.3, 24.0.1, 25.0.0, 25.0.2, 25.0.3, 26.0.0, 26.0.2, 27.0.3, 28.0.0, 28.0.2, 28.0.3
API Levels: 22, 24, 26, 27, 28
IDEs:
Android Studio: 3.2 AI-181.5540.7.32.5014246
Xcode: 10.2/10E125 - /usr/bin/xcodebuild
npmPackages:
react: 16.8.5 => 16.8.5
react-native: 0.59.2 => 0.59.2
npmGlobalPackages:
react-native-cli: 2.0.1
react-native-git-upgrade: 0.2.7

Platforms

iOS

Versions

  • react-native-netinfo:
  • react-native: 0.59.2
  • react: 16.8.5

Description

Uses old version of React and when adding the React dependecies from the node_modules directory (which is a really stupid way to do this) CocoaPods crashes. Isn't there really a better way to add dependencies with just package.json as all other dependencies? Really don't understand why some developers choose this CocoaPods way, which never works.

pod 'yoga', path: './node_modules/react-native/ReactCommon/yoga'
  pod 'Folly', :podspec => './node_modules/react-native/third-party-podspecs/Folly.podspec'
  pod 'GLog', :podspec => './node_modules/react-native/third-party-podspecs/GLog.podspec'
  pod 'DoubleConversion', :podspec => '../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec'
  pod 'React', path: './node_modules/react-native', subspecs: [
    'Core',
    'jschelpers',
    'cxxreact',
    'CxxBridge',
    'DevSupport',
    'RCTText',
    'RCTImage',
    'RCTNetwork',
    'RCTActionSheet',
    'RCTAnimation',
    'RCTWebSocket'
  ]

.rvm/gems/ruby-2.2.1@global/gems/gh_inspector-1.0.3/lib/gh_inspector/sidekick.rb:91:in `block in validate_delegate': #<Pod::UserInterface::InspectorReporter:0x007f811242da48> does not handle inspector_successfully_recieved_report (RuntimeError)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.