# use-timeout-mock-interval

> A custom React Hook that provides a declarative setTimeout mock setInterval called useTimeoutMockInterval.

Latest version **1.0.0** (published 2021-02-24) · MIT license · 0 weekly downloads

## Install

```sh
npm install use-timeout-mock-interval
pnpm add use-timeout-mock-interval
yarn add use-timeout-mock-interval
bun add use-timeout-mock-interval
```

## Health

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

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2021-02-24 |
| First published | 2021-02-24 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=10 |
| Dependencies | 1 |
| Unpacked size | 14.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | xigua1994 |
| Maintainers | xigua1994 |

## Links

- npm: https://www.npmjs.com/package/use-timeout-mock-interval
- npm.io page: https://npm.io/package/use-timeout-mock-interval

## Dependencies (1)

- [@testing-library/jest-dom](https://npm.io/package/@testing-library/jest-dom.md) ^5.11.9

## Recent versions

- 1.0.0 (latest) — 2021-02-24

## README

# use-timeout-mock-interval

A custom React Hook that provides a declarative setTimeout mock setInterval called useTimeoutMockInterval.

[![NPM](https://img.shields.io/npm/v/use-timeout-mock-interval.svg)](https://www.npmjs.com/package/use-timeout-mock-interval)

## Installation

```
$ npm i use-timeout-mock-interval
```

or

```
$ yarn add use-timeout-mock-interval
```

## Usage

```
useTimeoutMockInterval(fn, delay);
```
### Parameters

Here are the parameters that you can use.

| Parameter  | Description                                                                      |
| :--------- | :------------------------------------------------------------------------------- |
| `fn` | A function that will be called every `delay` milliseconds.                       |
| `delay`    | A number representing the delay in msecs. Set to `null` to "pause" the interval. |

## Example

```
import React, { useState } from 'react';
import useTimeoutMockInterval from 'use-timeout-mock-interval';

const Counter = ({ delay = 1000 }) => {
  const [count, setCount] = useState(0);

  useTimeoutMockInterval(() => {
    setCount((currentCount) => currentCount + 1);
  }, delay);

  return <h1>{count}</h1>;
};

export default Counter;
```

## License

**[MIT](LICENSE)** Licensed

---
_Source: https://npm.io/package/use-timeout-mock-interval · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
