react-redux-internet-connection
Check internet connection from your redux's state
Last updated 2 years ago by alirezavalizade .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install react-redux-internet-connection 
SYNC missed versions from official npm registry.

react-redux-internet-connection

Check internet connection from your redux's state

Installation

npm:

npm install react-redux-internet-connection

yarn:

yarn add react-redux-internet-connection

Config

In your main reducers

import { combineReducers } from 'redux';
import { reducer as internet } from 'react-redux-internet-connection';

const rootReducer = combineReducers({
  internet
});
export default rootReducer;

And you just need to add ReactReduxInternetConnection in App.js

import React, { PureComponent } from 'react';
import { ReactReduxInternetConnection } from 'react-redux-internet-connection';

class App extends PureComponent {

  render() {
    return (
      <div className="App">
        <h1>react-internet-connection</h1>
        <ReactReduxInternetConnection />
      </div>
    );
  }
}

export default App;

Usage

import React, { PureComponent } from 'react';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';

// you can access in every where to internet connection :)
@connect(state => ({
  connection: state.internet.connection
}), { })

export default class Home extends PureComponent {
  static propTypes = {
    connection: PropTypes.bool,
  };

  render() {
    const { connection } = this.props;
    return (
      <div>
        {connection &&
        <h1>connected :)</h1>}
        {!connection &&
        <h1>disconnected :(</h1>}
      </div>
    );
  }
}

Current Tags

  • 0.1.0                                ...           latest (2 years ago)

1 Versions

  • 0.1.0                                ...           2 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 1
Last Day 0
Last Week 1
Last Month 0
Dependents (0)
None

Copyright 2014 - 2017 © taobao.org |