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

Showing network connectivity status

In this recipe, we will learn how to use Redux to keep the state of the network status. When we lose network connectivity, we will display an alert message to inform the user there's no network available.

Getting ready

This recipe depends on the previous one. We are going to use the NetInfo class to listen to network changes, then we will keep the status of the network an the store and display an alert when the device is offline.

How to do it...

  1. We will start by creating the action that we will trigger when the network status changes. This action will receive the current type of network the device is connected to, for example, wifi, cell, vpn, and so on. If the type is none, it means the device is offline. Let's ...

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