@am-hooks/use-network

Detect offline status online

Usage no npm install needed!

<script type="module">
  import amHooksUseNetwork from 'https://cdn.skypack.dev/@am-hooks/use-network';
</script>

README

useNetwork

온라인 오프라인 상태를 감지

Installation

yarn

yarn add @am-hooks/use-network

npm

npm i @am-hooks/use-network

Usage

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

const App = () => {
  const handleNetworkChange = online => {
    console.log(online ? "We just went online" : "We are offline");
  };
  const onLine = useNetwork(handleNetworkChange);

  return <h2>{onLine ? "OnLine" : "Offline"}</h2>
}