npm

@ian_test_nooks/use-network

1.0.0 • Public • Published

@ian_test_nooks/use-network

React Hook to check online/offline

npm i @ian_test_nooks/use-network

const network status = useNetwork(network change listenner function);

import useNetwork from "@ian_test_nooks/use-network";

const App = () => {
  const handleNetworkChange = (online) => {
    console.log(online ? "we Just went online" : "we are offline");
  };
  const onLine = useNetwork(handleNetworkChange);
  return (
    <div className="App">
      <div>{onLine ? "Online" : "Offline"}</div>
    </div>
  );
};

Dependents (0)

Package Sidebar

Install

npm i @ian_test_nooks/use-network

Weekly Downloads

1

Version

1.0.0

License

MIT

Unpacked Size

1.86 kB

Total Files

4

Last publish

Collaborators

  • iian