react-interval-hook
Version:
React hook for using self-correcting setInterval, augmented by management methods (start, stop, isActive)
57 lines (37 loc) • 1.58 kB
Markdown
# React Interval Hook
[](https://codecov.io/gh/minwork/react)


[](https://www.npmjs.com/package/react-interval-hook)


> React _self-correcting_ interval hook for precision timing, augmented by management methods
## Main features
- Self-correcting ([explanation](https://stackoverflow.com/a/29972322/10322539))
- Manageable (start, stop, isActive)
- Thoroughly tested
## Installation
```bash
yarn add react-interval-hook
```
or
```bash
npm install --save react-interval-hook
```
# Basic usage
```tsx
import React from 'react'; // No longer necessary in newer React versions
import { useInterval } from 'react-interval-hook';
export const Example = () => {
useInterval(() => {
console.log('I am called every second');
});
return null;
};
```
# Documentation
Full documentation can be found [here](https://minwork.gitbook.io/react-interval-hook/)
# Support
If you like my work, consider making a [donation](https://github.com/sponsors/minwork) through Github Sponsors.
# License
MIT © [minwork](https://github.com/minwork)