Skip to content

Latest commit

 

History

History
28 lines (19 loc) · 680 Bytes

useOnlineState.md

File metadata and controls

28 lines (19 loc) · 680 Bytes

useOnlineState

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.

Why? 💡

  • You want to your component to re-render ether when the connection goes online or offline.

Basic Usage:

import { useOnlineState } from 'beautiful-react-hooks'; 

const ConnectionTest = () => {
   const isOnline = useOnlineState();
      
   return (
     <DisplayDemo>
       <p>Connection status: {isOnline ? 'online' : 'offline'}</p>
     </DisplayDemo>
   );
};

<ConnectionTest />