GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - Hermanya/use-interval: ⏲ Dan Abramov's interval hook.

BranchesTags
Open more actions menu

Latest commit

 

History

229 Commits
229 Commits

Folders and files

NameName
Last commit message
Last commit date
.github
.github
 
 
example
example
 
 
src
src
 
 
.editorconfig
.editorconfig
 
 
.gitignore
.gitignore
 
 
.prettierrc
.prettierrc
 
 
.travis.yml
.travis.yml
 
 
CHANGELOG
CHANGELOG
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
package.json
package.json
 
 
rollup.config.js
rollup.config.js
 
 
tsconfig.json
tsconfig.json
 
 
yarn.lock
yarn.lock
 
 

Repository files navigation

use-interval

React hook for setting an interval as posted on overreacted.io

NPM JavaScript Style Guide

Dan Abramov's blog post explaining why you cannot just use setInterval within useEffect.

Used by

  • openai / codex
  • codesandbox / codesandbox-client
  • kentcdodds / react-performance
  • siddharthkp / react-ui
  • element-motion
  • wintercounter / mhy
  • sagemathinc / cocalc
  • wintercounter / mhy

Install

npm install --save use-interval

Usage

import * as React from 'react'

import useInterval from 'use-interval'

const Example = () => {
  let [count, setCount] = React.useState(0);

  useInterval(() => {
    // Your custom logic here
    setCount(count + 1);
  }, 1000); // passing null instead of 1000 will cancel the interval if it is already running

  return <h1>{count}</h1>;
}
// TypeScript Declaration
useInterval(
  callback: () => void,
  delay: number,
  immediate?: boolean /* called when mounted if true */
)

License

MIT


This hook is created using create-react-hook.

About

⏲ Dan Abramov's interval hook.

www.npmjs.com/package/use-interval

Resources

Readme
MIT license
Activity

Stars

70 stars

Watchers

2 watching

Forks

9 forks
Report repository

Releases

Sponsor this project

Packages

Used by

Contributors

Languages

You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.