@rehooks/network-status
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

@rehooks/network-status

React hook for getting network-status

Note: This is using the new React Hooks API Proposal which is subject to change until React 16.7 final.

You'll need to install react, react-dom, etc at ^16.7.0-alpha.0

Install

yarn add @rehooks/network-status

Usage

import useNetworkStatus from "@rehooks/network-status";

function MyComponent() {
  let connection = useNetworkStatus();
  return (
    <div>
      <div>downlink: {connection.downlink}</div>
      <div>effectiveType: {connection.effectiveType}</div>
      <div>rtt: {connection.rtt}</div>
      <div>saveData: {connection.saveData ? "yes" : "no"}</div>
    </div>
  );
}

Package Sidebar

Install

npm i @rehooks/network-status

Weekly Downloads

1

Version

1.0.0

License

MIT

Unpacked Size

3.85 kB

Total Files

6

Last publish

Collaborators

  • hanford
  • jmoxey
  • iamsolankiamit
  • fouad
  • mathdroid
  • thejameskyle