use-throttle
Throttle hook for react

use-throttle downloads use-throttle version use-throttle license

use-throttleSimilar Packages:
Npm Package Weekly Downloads Trend
3 Years
🌟 Show real-time usage chart on use-throttle's README.md, just copy the code below.
## Usage Trend
[![Usage Trend of use-throttle](https://npm-compare.com/img/npm-trend/THREE_YEARS/use-throttle.png)](https://npm-compare.com/use-throttle#timeRange=THREE_YEARS)
Cumulative GitHub Star Trend
🌟 Show GitHub stars trend chart on use-throttle's README.md, just copy the code below.
## GitHub Stars Trend
[![GitHub Stars Trend of use-throttle](https://npm-compare.com/img/github-trend/use-throttle.png)](https://npm-compare.com/use-throttle)
Stat Detail
Package
Downloads
Stars
Size
Issues
Publish
License
use-throttle10,6363992.2 kB0-MIT
README for use-throttle

useThrottle react hook

Install it with yarn:

yarn add use-throttle

Or with npm:

npm i use-throttle --save

Demo

The simplest way to start playing around with use-throttle is with this CodeSandbox snippet: https://codesandbox.io/s/18yyn08y7

Simple Throttle

According to https://twitter.com/dan_abramov/status/1060729512227467264

import React, { useState } from 'react';
import { useThrottle } from 'use-throttle';

export default function Input() {
  const [text, setText] = useState('Hello');
  const throttledText = useThrottle(text, 1000);

  return (
    <div>
      <input
        defaultValue={'Hello'}
        onChange={(e) => {
          setText(e.target.value);
        }}
      />
      <p>Actual value: {text}</p>
      <p>Throttle value: {throttledText}</p>
    </div>
  );
}