How to use the @react-native-community/netinfo.NetInfoStateType 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 microsoft / reactxp / extensions / netinfo / src / native-common / NetInfo.tsx View on Github external
private static _getNetworkTypeFromConnectionInfo(state: RNNetInfo.NetInfoState): Types.DeviceNetworkType {
        if (state.type === RNNetInfo.NetInfoStateType.cellular) {
            if (state.details === null || state.details.cellularGeneration === null) {
                return Types.DeviceNetworkType.Unknown;
            } else if (state.details.cellularGeneration === '2g') {
                return Types.DeviceNetworkType.Mobile2G;
            } else if (state.details.cellularGeneration === '3g') {
                return Types.DeviceNetworkType.Mobile3G;
            } else if (state.details.cellularGeneration === '4g') {
                return Types.DeviceNetworkType.Mobile4G;
            }
        } else if (state.type === RNNetInfo.NetInfoStateType.wifi ) {
            return Types.DeviceNetworkType.Wifi;
        } else if (state.type === RNNetInfo.NetInfoStateType.ethernet ) {
            return Types.DeviceNetworkType.Wifi;
        } else if (state.type === RNNetInfo.NetInfoStateType.wimax ) {
            return Types.DeviceNetworkType.Wifi;
        } else if (state.type === RNNetInfo.NetInfoStateType.none) {
github microsoft / reactxp / extensions / netinfo / src / native-common / NetInfo.tsx View on Github external
private static _getNetworkTypeFromConnectionInfo(state: RNNetInfo.NetInfoState): Types.DeviceNetworkType {
        if (state.type === RNNetInfo.NetInfoStateType.cellular) {
            if (state.details === null || state.details.cellularGeneration === null) {
                return Types.DeviceNetworkType.Unknown;
            } else if (state.details.cellularGeneration === '2g') {
                return Types.DeviceNetworkType.Mobile2G;
            } else if (state.details.cellularGeneration === '3g') {
                return Types.DeviceNetworkType.Mobile3G;
            } else if (state.details.cellularGeneration === '4g') {
                return Types.DeviceNetworkType.Mobile4G;
            }
        } else if (state.type === RNNetInfo.NetInfoStateType.wifi ) {
            return Types.DeviceNetworkType.Wifi;
        } else if (state.type === RNNetInfo.NetInfoStateType.ethernet ) {
            return Types.DeviceNetworkType.Wifi;
        } else if (state.type === RNNetInfo.NetInfoStateType.wimax ) {
            return Types.DeviceNetworkType.Wifi;
        } else if (state.type === RNNetInfo.NetInfoStateType.none) {
            return Types.DeviceNetworkType.None;
        }

        return Types.DeviceNetworkType.Unknown;
    }
}