Giter Site home page Giter Site logo

lancej1022 / use-interval Goto Github PK

View Code? Open in Web Editor NEW

This project forked from hermanya/use-interval

0.0 1.0 0.0 635 KB

⏲ Dan Abramov's interval hook.

Home Page: https://www.npmjs.com/package/use-interval

License: MIT License

HTML 11.74% JavaScript 6.32% CSS 6.32% TypeScript 75.63%

use-interval's Introduction

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

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);

  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.

use-interval's People

Contributors

hermanya avatar dependabot[bot] avatar dependabot-preview[bot] avatar leonardodino avatar g-rath avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.