react-use-online-offline
v1.0.9
Published
React Online Offline
Downloads
11
Maintainers
Readme
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