O'Reilly logo

React Native Cookbook by Crysfel Villa, Stan Bershadskiy

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Mask the application upon network connection loss

Internet connection is not always available, especially when people are moving around the city, on the train, or hiking in the mountains. A good user experience will inform the user when the connection is lost.

In this recipe, we will create an app that shows a message when a network connection is lost.

Getting ready

We need to create an empty app named MaskNetwork. If you use a different name, make sure you use the same when registering the app.

For Android, add the following permission to your AndroidManifest.xml:

<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

How to do it...

  1. Let's open the index.ios.js and index.android.js files, remove the existing code, and add the following: ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required