Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-debounce-hook

Package Overview
Dependencies
Maintainers
2
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-debounce-hook

A react hook for using a debouncing an input with state variables In react.

  • 1.1.19
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2.1K
decreased by-1.22%
Maintainers
2
Weekly downloads
 
Created
Source

use-debounce

A react hook for debouncing an input with state variables in react.

Usage

Simple demo
react-select demo

import React, { useState } from 'react';

const MyComponent() {
  const [value, setValue] = useState();
  const [debouncedValue, setDebouncedValue] = useState();

  useDebounce(value, setDebouncedValue);

  return (
    <div>
      <input onChange={({ target: { value } }) => setValue(value)} />
      
      {debouncedValue}
    </div>
  );
}

Parameters

value
value: any

Whenever this variable changes, the debounce method is triggered and the timer is started.

operation
operation: (value, ...params) => {...}

If the debounce timer ended without interruption, we call operation with the freshest value of value (+ all the params passed as 4+ arguments.)

delay
delay: number = 400

The debounce delay - after this amount of time operation will be called (without interruption of getting a new value).

params
params: any {...params}

Additional arguments to be passed to your operation, will be spread in the order that were passed.

Keywords

FAQs

Package last updated on 19 Nov 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc