React hook that works like circuit breaker.
npm install --save react-use-circuit-breaker
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!
MIT © h-tachikawa
This hook is created using create-react-hook.