@hooks2022/use-network

1.0.0 • Public • Published

@hooks2022/use-network

React Hook to listen when the user goes online or offline.

Installation

yarn

yarn add @hooks2022/use-network

npm

npm i @hooks2022/use-network

Usage

import React from "react";
import useNetwork from "@hooks2022/use-network";

function App() {
  const onNetworkChange = (isOnline) =>
    console.log(isOnline ? "We are back online" : "We just got offline");
  const isOnline = useNetwork(onNetworkChange);
  return <h1>{isOnline ? "We are online" : "We are offline"}</h1>;
}

Readme

Keywords

Package Sidebar

Install

npm i @hooks2022/use-network

Weekly Downloads

0

Version

1.0.0

License

MIT

Unpacked Size

1.76 kB

Total Files

4

Last publish

Collaborators

  • heejinkim