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

@jdthornton/useinterval

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@jdthornton/useinterval

React interval hook

latest
Source
npmnpm
Version
1.0.3
Version published
Maintainers
1
Created
Source

@jdthornton/useinterval

npm (scoped) npm bundle size (minified)

React interval hook.

Install

$ npm install @jdthornton/useinterval

Usage

import { useState } from 'react';
import useInterval from "@jdthornton/useinterval";

function App(){
  const [ isCountActive, setIsCountActive ] = useState();
  const [ count, setCount ] = useState(0);
  const handleCountToggle = () => setIsCountActive(prevIsCountActive => !prevIsCountActive)
  useInterval(
    () => setCount(prevCount => prevCount + 1),
    isCountActive ? 1000 : null
  )
  return(
    <div>
      <div>Count: {count}</div>
      <button type="button" onClick={handleCountToggle}>
        {isCountActive ? "Stop" : "Start"}
      </button>
    </div>
  )
}

FAQs

Package last updated on 17 Dec 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