https://github.com/use-hooks/react-hooks-interval
Custom React Hooks for setInterval
https://github.com/use-hooks/react-hooks-interval
react-hooks reactjs setinterval
Last synced: 24 days ago
JSON representation
Custom React Hooks for setInterval
- Host: GitHub
- URL: https://github.com/use-hooks/react-hooks-interval
- Owner: use-hooks
- License: mit
- Created: 2019-02-05T12:48:46.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2023-12-15T05:56:50.000Z (about 2 years ago)
- Last Synced: 2025-10-13T00:21:27.573Z (5 months ago)
- Topics: react-hooks, reactjs, setinterval
- Language: JavaScript
- Homepage:
- Size: 313 KB
- Stars: 7
- Watchers: 1
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# react-hooks-interval
[![NPM version][npm-image]][npm-url]
[![npm download][download-image]][download-url]
[![Build Status][travis-image]][travis-url]
Custom React Hooks for setInterval
## Install
>**Note:** Make sure that you have installed the correct version of `react(>= v16.8.0)` and `react-dom(>= v16.8.0)`.
### npm
```bash
npm install --save @use-hooks/interval
```
### yarn
```bash
yarn add @use-hooks/interval
```
## API
### Params
```js
/**
* Params
* @param {function} callback - Custom logic function
* @param {number|null} delay - Delayed millisecond, stop if null
*/
```
### Returns
```js
/**
* Returns
*/
```
## Usage
```js
import React, { useState } from 'react';
import useInterval from '@use-hooks/interval';
export default function App() {
const [count, setCount] = useState(0);
useInterval(() => {
setCount(count + 1);
}, 1000);
return (
DEMO of @use-hooks/interval
Count: {count}s
);
}
```
[Live Show](https://use-hooks.github.io/react-hooks-interval/)
## Development
> Node >= v8 LTS
- Clone the project to local disk
- `npm install`
- `npm start`
## License
MIT
> Generated by [create-react-hooks](https://github.com/use-hooks/create-react-hooks).
[npm-image]: https://img.shields.io/npm/v/@use-hooks/interval.svg?style=flat-square
[npm-url]: https://npmjs.org/package/@use-hooks/interval
[download-image]: https://img.shields.io/npm/dm/@use-hooks/interval.svg?style=flat-square
[download-url]: https://npmjs.org/package/@use-hooks/interval
[travis-url]: https://travis-ci.com/use-hooks/react-hooks-interval
[travis-image]: https://img.shields.io/travis/com/use-hooks/react-hooks-interval.svg?style=flat-square