1.0.0 • Published 5 years ago

@am-hooks/use-network v1.0.0

Weekly downloads
1
License
MIT
Repository
github
Last release
5 years ago

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>
}