Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Detect and handle slow internet connection in React-Native

Currently I am using NetInfo of react-native and with the help of EffectiveConnectionType, I am able to find the connection is in : 2g, 3g, 4g and unknown. But is there any optimise way to handle this problem ?

like image 445
yogeshwar nair Avatar asked May 29 '18 10:05

yogeshwar nair


People also ask

How detect slow internet connection react native?

You can use https://github.com/rgommezz/react-native-offline or you can simply add timeout in axios...if request is aborted after particular time say 10 sec... re-hit the same API request and set the count limit if count limit exceeds... You can show the slow internet message. Save this answer.

How do I check my network strength in react native?

If you just want to know whether the device has an active internet connection, you can use e.g. isConnected from React Native's NetInfo: import { NetInfo } from "react-native"; NetInfo.

How check network or not in react native?

NetInfoState APItype – Returns the NetInfoStateType of the current connection (cellular, wifi, bluetooth, etc..) isConnected – Boolean value that tells if there is an active network connection. isWifiEnabled (Android only) – Boolean value indicating if wifi is enabled or not.


1 Answers

You can use https://github.com/rgommezz/react-native-offline or you can simply add timeout in axios...if request is aborted after particular time say 10 sec...re-hit the same API request and set the count limit if count limit exceeds...You can show the slow internet message.

like image 163
yogeshwar nair Avatar answered Sep 24 '22 06:09

yogeshwar nair