# @jdthornton/useinterval

> React interval hook

Latest version **1.0.3** (published 2021-12-17) · MIT license · 0 weekly downloads

## Install

```sh
npm install @jdthornton/useinterval
pnpm add @jdthornton/useinterval
yarn add @jdthornton/useinterval
bun add @jdthornton/useinterval
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.3 |
| Published | 2021-12-17 |
| First published | 2021-09-30 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 3.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Jake Thornton |
| Maintainers | jdthornton |

## Links

- npm: https://www.npmjs.com/package/@jdthornton/useinterval
- Repository: https://github.com/jdthornton/useinterval
- Homepage: https://github.com/jdthornton/useinterval#readme
- Issues: https://github.com/jdthornton/useinterval/issues
- npm.io page: https://npm.io/package/@jdthornton/useinterval

## Dependencies (1)

- [@jdthornton/usecallbackref](https://npm.io/package/@jdthornton/usecallbackref.md) ^1.0.2

## Recent versions

- 1.0.3 (latest) — 2021-12-17
- 1.0.2 — 2021-10-10
- 1.0.1 — 2021-09-30

## README

# @jdthornton/useinterval

[![npm (scoped)](https://img.shields.io/npm/v/@jdthornton/useinterval.svg)](https://www.npmjs.com/package/@jdthornton/useinterval)
[![npm bundle size (minified)](https://img.shields.io/bundlephobia/min/@jdthornton/useinterval.svg)](https://www.npmjs.com/package/@jdthornton/useinterval)

React interval hook.

## Install

```
$ npm install @jdthornton/useinterval
```

## Usage

```js
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>
  )
}
```

---
_Source: https://npm.io/package/@jdthornton/useinterval · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
