Socket
Book a DemoInstallSign in
Socket

react-native-redux-connectivity

Package Overview
Dependencies
Maintainers
5
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-native-redux-connectivity

Monitor network connectivity and story the result in Redux

0.2.1
latest
Source
npmnpm
Version published
Weekly downloads
15
-91.94%
Maintainers
5
Weekly downloads
 
Created
Source

react-native-redux-connectivity

Monitor network connectivity and store the result in Redux

Monitors:

  • Network connectivity
  • Network type (e.g. wifi)

This library is compatible with React Native 0.57 and up only. For compatibility with earlier versions of React Native, please use version 0.2.0

Installation

npm install react-native-redux-connectivity

or

yarn add react-native-redux-connectivity

You will also need to add @react-native-community/netinfo and follow the instructions to link the library

npm install --save @react-native-community/netinfo

or

react-native link @react-native-community/netinfo

Usage

In your main app component:

import {NetworkMonitor} from 'react-native-redux-connectivity'
const store = [IMPORT YOUR REDUX STORE HERE]

class App extends Component {
  constructor(props) {
    super(props);
    this.networkMonitor = new NetworkMonitor(store);
    this.networkMonitor.start();
 }
 
 componentWillUnmount() {
  this.networkMonitor.stop();
 }
}

In your root reducer:

import {combineReducers} from 'redux';
import {NetworkReducer} from 'react-native-redux-connectivity';

/**
 * When new reducers are added, put them here
 */
export default combineReducers({
  network: NetworkReducer,
  // .. your other reducers
});

You'll then see in Redux:

network: { 
  connected: boolean, // true if there's an Internet connection
  connectionType: 'none'|'wifi'|'cell'|'unknown',
  effectiveType: '2g'|'3g'|'4g'|'unknown',
}

Keywords

react

FAQs

Package last updated on 12 Dec 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.