New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

use-set-timeout

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

use-set-timeout

A React Hook (using useEffect) which uses window.setTimeout().

latest
Source
npmnpm
Version
1.0.4
Version published
Weekly downloads
21
5%
Maintainers
1
Weekly downloads
 
Created
Source

Project Homepage : Documentation and Examples

useSetTimeout

A React Hook (using useEffect) which uses window.setTimeout().

Synopsis

In your React component:

import { useState } from 'react'
import useSetTimeout from "use-set-timeout"

function SetTimeout() {
  const [ triggered, setTriggered ] = useState(false)

  useSetTimeout(() => { setTriggered(true) }, 5 * 1000)

  return <p>triggered = { triggered }</p>
}

There is no need to keep a reference to the timeout ID since it will be automatically cleared when the component unmounts.

Please note that the timeout is cleared and reset if you change the timeout ms but not if you change the function fn.

Usage

useSetTimeout(fn, delay)
  • fn is a function to execute
  • delay is the delay in milliseconds

Other Hooks

Please see all of the other reacthooks.org hooks:

Author

$ npx chilts

   ╒════════════════════════════════════════════════════╕
   │                                                    │
   │   Andrew Chilton (Personal)                        │
   │   -------------------------                        │
   │                                                    │
   │          Email : andychilton@gmail.com             │
   │            Web : https://chilts.org                │
   │        Twitter : https://twitter.com/andychilton   │
   │         GitHub : https://github.com/chilts         │
   │         GitLab : https://gitlab.org/chilts         │
   │                                                    │
   │   Apps Attic Ltd (My Company)                      │
   │   ---------------------------                      │
   │                                                    │
   │          Email : chilts@appsattic.com              │
   │            Web : https://appsattic.com             │
   │        Twitter : https://twitter.com/AppsAttic     │
   │         GitLab : https://gitlab.com/appsattic      │
   │                                                    │
   │   Node.js / npm                                    │
   │   -------------                                    │
   │                                                    │
   │        Profile : https://www.npmjs.com/~chilts     │
   │           Card : $ npx chilts                      │
   │                                                    │
   ╘════════════════════════════════════════════════════╛

(Ends)

Keywords

react

FAQs

Package last updated on 16 Dec 2019

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