Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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;
}
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
}
}
const toPut = yield Saga.callUntyped(() =>
NetInfo.getConnectionInfo().then(({type}) =>
ConfigGen.createOsNetworkStatusChanged({isInit: true, online: type !== 'none'})
)
)
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);
};
});