Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
1 contributor

Users who have contributed to this file

28 lines (19 sloc) 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 />
You can’t perform that action at this time.