How to use the @react-native-community/netinfo.getConnectionInfo function in @react-native-community/netinfo

To help you get started, we’ve selected a few @react-native-community/netinfo examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github expo / expo / apps / native-component-list / src / screens / NetInfoScreen.tsx View on Github external
componentDidMount() {
    this._eventCounter = 0;

    NetInfo.getConnectionInfo()
      .then(connectionInfo => this.setState({ connectionInfo }))
      .catch(console.warn);
    this._ensureIsConnectionExpensiveIsUpToDate();
    this._subscription = NetInfo.addEventListener(
      'connectionChange',
      this._handleConnectionChange
    ) as unknown as Subscription;
    this._isConnectedSubscription = NetInfo.isConnected.addEventListener(
      'connectionChange',
      this._handleIsConnectedChange
    ) as unknown as Subscription;
  }
github celo-org / celo-monorepo / packages / mobile / src / utils / LogUploader.ts View on Github external
static async isConnectionWifi(): Promise {
    const connectionInfo = await NetInfo.getConnectionInfo()
    const isConnectionExpensive = await NetInfo.isConnectionExpensive()
    Logger.debug(TAG, `isConnectionWifi/Connection type is ${connectionInfo.type}`)
    Logger.debug(TAG, `isConnectionWifi/is connection expensive: ${isConnectionExpensive}`)
    return connectionInfo.type.toString().toLowerCase() === 'wifi' && !isConnectionExpensive
  }
}
github keybase / client / shared / actions / platform-specific / index.native.js View on Github external
const toPut = yield Saga.callUntyped(() =>
    NetInfo.getConnectionInfo().then(({type}) =>
      ConfigGen.createOsNetworkStatusChanged({isInit: true, online: type !== 'none'})
    )
  )
github CodeRabbitYu / ShiTu / app / components / BaseContainer / index.js View on Github external
useEffect(() => {
    NetInfo.getConnectionInfo().then(networkHandle);
    if (netInfoListen) {
      NetInfo.removeEventListener('connectionChange', networkHandle);
    } else {
      netInfoListen = NetInfo.addEventListener('connectionChange', networkHandle);
    }

    return () => {
      props.store && props.store.hideLoading();
      netInfoListen && NetInfo.removeEventListener('connectionChange', networkHandle);
    };
  });