npm.io
1.0.9 • Published 2 years ago

react-use-online-offline

Licence
MIT
Version
1.0.9
Deps
4
Size
6 kB
Vulns
0
Weekly
0

Name

React Online Offline

Install

npm i react-use-online-offline

Code

import { ReactOnlineOffline } from 'react-use-online-offline';
import 'react-use-online-offline/dist/style.css';

  const UseOnlineOffline=()=>{
  const { isOnline } = ReactOnlineOffline();

    return (
      <React.Fragment>
        <div className="msgbox">{isOnline===true? 'You are online':'You are offline'}</div>
      </React.Fragment>
    );
  }

Add body id in public/index.html

<body id="body">

If need black and white grayscale when offline add this css in your project

  .offline{
    filter: grayscale(100%);
    overflow:hidden;
  }

Demo

See the output https://ibb.co/wRVSy2V

Keywords