Skip to content

Files

Latest commit

5881fa6 Β· Oct 27, 2018

History

History
29 lines (23 loc) Β· 404 Bytes

useNetwork.md

File metadata and controls

29 lines (23 loc) Β· 404 Bytes

useNetwork

React sensor hook that tracks connected hardware devices. Returns:

{
  "online": true,
  "since": "2018-10-27T08:59:05.562Z",
  "downlink": 10,
  "effectiveType": "4g",
  "rtt": 50
}

Usage

import {useNetwork} from 'react-use';

const Demo = () => {
  const state = useNetwork();

  return (
    <pre>
      {JSON.stringify(state, null, 2)}
    </pre>
  );
};