I need to check Internet Connection while Application Background
The most popular methods to achieve offline support in React Native are by implementing usage restrictions, caching, and request queuing.
You'll need internet connection to install the React Native CLI and create your app (this will fetch React Native and its JavaScript dependencies). You'll also need internet connection the first time you run react-native run-android because this will download third-party Android dependencies.
import { NetInfo } from 'react-native';
NetInfo.isConnected.fetch().then(isConnected => {
if(isConnected)
{
console.log('Internet is connected');
}
})
This above code is sufficient to check if there is active net connection or not
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With