import { NetInfo } from 'react-native';
isConnected: true, // by default the app is assumed to have a connection
function reducer(state = initialState, action) {
case 'UPDATE_CONNECTIVITY' {
return Object.assign({}, state, { isConnected: action.payload });
// add event listeners to update the connectivity flag when the
// connection status changes
NetInfo.isConnected.addEventListener('change', (isConnected) => {
type: 'UPDATE_CONNECTIVITY',