use-cooldown
TypeScript icon, indicating that this package has built-in type declarations

1.0.8 • Public • Published

use-cooldown

A React hook implementation for client-side rate limiting.

NPM JavaScript Style Guide Build Status

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.

Readme

Keywords

none

Package Sidebar

Install

npm i use-cooldown

Weekly Downloads

7

Version

1.0.8

License

MIT

Unpacked Size

1000 kB

Total Files

29

Last publish

Collaborators

  • vvella