0.0.2 • Published 6 years ago

is-online-component v0.0.2

Weekly downloads
5
License
MIT
Repository
github
Last release
6 years ago

is-online-component

npm Build Status npm.io

A simple react component that detects online and offline changes

Live demo here

npm.io

Usage

$ npm install is-online-component
# OR
$ yarn add is-online-component
import React from 'react';
import IsOnline from 'is-online-component ';

const handleChange = (isOnline) => {
  console.log(isOnline);
};

const App = () => (
  <div>
    <IsOnline
      OnlineComponent={<h1>online</h1>}
      OfflineComponent={<h1>offline</h1>}
      onChange={handleChange}
    />
  </div>
);

export default App;

View demo here Edit is-online-component

Props

Following props are used while initialization

Prop NameTypeDescription
OnlineComponent (optional)React.Component or Stringthe component that will be renderized when browser is online
OfflineComponent (optional)React.Component or Stringthe component that will be renderized when browser is offline
onChange (optional)Functionfunction that will be called when the navigator be online or offline