
Security News
Node.js TSC Votes to Stop Distributing Corepack
Corepack will be phased out from future Node.js releases following a TSC vote.
react-useinterval
Advanced tools
A custom React hook that wraps JavaScript's setInterval function.
$ npm install --save react-useinterval
useInterval(callback, delay, ...args)
Property | Type | Required | Description |
---|---|---|---|
callback | Function | Yes | A function to be executed every delay milliseconds. |
delay | Number , undefined , or null | No | The time, in milliseconds, that the timer should delay in between executions of the specified function. Note: If undefined or null is passed, the interval will be paused. |
...args | Any | No | Additional arguments which are passed through to the function specified by callback. |
This creates a counter that counts up by five every second.
import React, { useState } from 'react';
import useInterval from 'react-useinterval';
function Counter() {
let [count, setCount] = useState(0);
const increaseCount = amount => {
setCount(count + amount);
};
useInterval(increaseCount, 1000, 5);
return <h1>{count}</h1>;
}
Inspired by Dan Abramov's blog post here.
FAQs
A custom React hook that wraps setInterval
The npm package react-useinterval receives a total of 4,412 weekly downloads. As such, react-useinterval popularity was classified as popular.
We found that react-useinterval demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
Corepack will be phased out from future Node.js releases following a TSC vote.
Research
Security News
Research uncovers Black Basta's plans to exploit package registries for ransomware delivery alongside evidence of similar attacks already targeting open source ecosystems.
Security News
Oxlint's beta release introduces 500+ built-in linting rules while delivering twice the speed of previous versions, with future support planned for custom plugins and improved IDE integration.