# react-use-circuit-breaker

> > React hook that works like circuit breaker.

Latest version **1.0.1** (published 2021-09-22) · MIT license · 0 weekly downloads

## Install

```sh
npm install react-use-circuit-breaker
pnpm add react-use-circuit-breaker
yarn add react-use-circuit-breaker
bun add react-use-circuit-breaker
```

## Health

**Score 45/100 (D)** — status: abandoned.

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

Warnings: low downloads.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2021-09-22 |
| First published | 2021-07-07 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=8 |
| Dependencies | 0 |
| Unpacked size | 1.3 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 4 |
| Author | h-tachikawa |
| Maintainers | h-tachikawa |

## Links

- npm: https://www.npmjs.com/package/react-use-circuit-breaker
- Repository: https://github.com/h-tachikawa/react-use-circuit-breaker
- Homepage: https://github.com/h-tachikawa/react-use-circuit-breaker#readme
- Issues: https://github.com/h-tachikawa/react-use-circuit-breaker/issues
- npm.io page: https://npm.io/package/react-use-circuit-breaker

## Recent versions

- 1.0.1 (latest) — 2021-09-22
- 1.0.0 — 2021-07-07

## README

# react-use-circuit-breaker

> React hook that works like circuit breaker.

[![NPM](https://img.shields.io/npm/v/react-use-circuit-breaker.svg)](https://www.npmjs.com/package/react-use-circuit-breaker) [![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)
[![Node.js CI](https://github.com/h-tachikawa/react-use-circuit-breaker/actions/workflows/node-test.yaml/badge.svg?branch=master)](https://github.com/h-tachikawa/react-use-circuit-breaker/actions/workflows/node-test.yaml)
[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)

## Install

```bash
npm install --save react-use-circuit-breaker
```

## Usage

```tsx
import { useCircuitBreaker } from 'react-use-circuit-breaker'

/**
 * Execute callback function that passed by third argument
 * when send function called 2 times in 5 seconds.
 */
const [send] = useCircuitBreaker(2, 5000, () => {
  throw new Error("The breaker trips!");
});

send();
send();
send(); // => Uncaught Error: The breaker trips!
```

## License

MIT © [h-tachikawa](https://github.com/h-tachikawa)

---

This hook is created using [create-react-hook](https://github.com/hermanya/create-react-hook).

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