1.0.0 • Published 6 years ago

@rehooks/network-status v1.0.0

Weekly downloads
44
License
MIT
Repository
github
Last release
6 years ago

@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>
  );
}