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 ...

Get React Native Cookbook now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.