🚀. Socket Launch Week Day 3:Socket Firewall Now Blocks Malicious VS Code and Open VSX Extensions.Learn more
Sign In

@rooks/use-timeout

Package Overview
Dependencies
Maintainers
1
Versions
122
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@rooks/use-timeout

A React Hooks package for timeout

Source
npmnpm
Version
4.9.2
Version published
Weekly downloads
1.2K
42.81%
Maintainers
1
Weekly downloads
 
Created
Source

@rooks/use-timeout

TitleCard

Build Status

About

setTimeout hook for react.

Installation

npm install --save @rooks/use-timeout

Importing the hook

import useTimeout from "@rooks/use-timeout"

Usage

function TimeoutComponent() {
  function doAlert() {
    window.alert("timeout expired!");
  }
  const { start, clear } = useTimeout(doAlert, 2000);
  return (
    <>
      <button onClick={start}> Start timeout </button>
      <button onClick={clear}> Clear timeout </button>
    </>
  );
}

render(<TimeoutComponent/>)

Arguments

ArgumentsTypeDescriptionDefault value
callbackfunctionFunction to be executed in timeoutundefind
delayNumberNumber in milliseconds after which callback is to be run0

Returned Object keys

Returned object attributesTypeDescription
clearfunctionClear the timeout
startfunctionStart the timeout
isActivebooleanIs the timeout active

Keywords

use

FAQs

Package last updated on 21 Feb 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts