React hook for subscribing to
online/offlineevents and thenavigator.onLineproperty to see current status
You'll need to install
react,react-dom, etc at^16.8.4
yarn add @rehooks/online-statusimport useOnlineStatus from '@rehooks/online-status';
function MyComponent() {
const onlineStatus = useOnlineStatus();
return (
<div>
<h1>You are {onlineStatus ? "Online" : "Offline"}</h1>
</div>
);
}