Skip to content

A simple react component that detect online and offline changes

License

Notifications You must be signed in to change notification settings

Leocardoso94/is-online-component

Repository files navigation

is-online-component

npm Build Status

A simple react component that detects online and offline changes

Live demo here

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 Name Type Description
OnlineComponent (optional) React.Component or String the component that will be renderized when browser is online
OfflineComponent (optional) React.Component or String the component that will be renderized when browser is offline
onChange (optional) Function function that will be called when the navigator be online or offline

About

A simple react component that detect online and offline changes

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published