Novelty Plastic Moustache

    @jacob-hooks/use-network

    1.0.16 • Public • Published

    @jacob-hooks/use-network

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

    installation

    yarn

    yarn add @jacob-hooks/use-network

    npm

    npm i @jacob-hooks/use-network

    Usage

    import React from "react";
    import useNetwork from "@jacob-hooks/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>;
    }

    Arguments

    Argument Type Description Arguments Required
    onNetworkChange function Function to be called when the network status changes isOnline : Boolean no

    Return

    Return value Type Description Default value
    isOnline Boolean A boolean representing if the user is online or not true

    Install

    npm i @jacob-hooks/use-network

    DownloadsWeekly Downloads

    0

    Version

    1.0.16

    License

    MIT

    Unpacked Size

    4.3 kB

    Total Files

    6

    Last publish

    Collaborators

    • jacobko