1.0.1 • Published 4 years ago

@lchooks/use-network v1.0.1

Weekly downloads
2
License
MIT
Repository
github
Last release
4 years ago

@lchooks/use-network

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

노마드코더 수업을 들으면서 클론코딩했습니다. Thank you nomadcoders!! https://academy.nomadcoders.co/p/introduction-to-react-hooks

Installation

yarn

yarn add @lchooks/use-network

npm

npm i @lchooks/use-network

Usage

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

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

Arguments

ArgumentTypeDescriptionArgumentsRequired
onNetworkChangefunctionFunction to be called when the network status changesisOnline : Booleanno

Return

Return valueTypeDescriptionDefault value
isOnlineBooleanA boolean representing if the user is online or nottrue
1.0.1

4 years ago

1.0.0

4 years ago