Uses the Navigator online API to define whether the browser is connected or not.
Returns a boolean
value that if is true indicates the browser is connected.
- You want to your component to re-render ether when the connection goes online or offline.
import { useOnlineState } from 'beautiful-react-hooks';
const ConnectionTest = () => {
const isOnline = useOnlineState();
return (
<DisplayDemo>
<p>Connection status: {isOnline ? 'online' : 'offline'}</p>
</DisplayDemo>
);
};
<ConnectionTest />