use-cooldown
v1.0.8
Published
A React hook implementation for client-side rate limiting.
Downloads
5
Readme
use-cooldown
A React hook implementation for client-side rate limiting.
Install
npm install --save use-cooldown
Usage
import * as React from 'react';
import { useCooldown } from 'use-cooldown';
const Example = () => {
const [cooledDown, setCooledDown] = useCooldown(1000); // pass in length of cooldown in ms
const startCooldown = () => setCooledDown(false);
return (
<div>
<div>{`${cooledDown}`}</div>
<button disabled={!cooledDown} onClick={startCooldown}>
Begin Cooldown
</button>
</div>
);
};
License
MIT © vincentvella
This hook is created using create-react-hook.