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

use-debounce

Package Overview
Dependencies
Maintainers
1
Versions
80
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

use-debounce

Debounce hook for react

  • 8.0.1-beta
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.6M
increased by5.09%
Maintainers
1
Weekly downloads
 
Created

What is use-debounce?

The use-debounce package provides a collection of hooks and functions to debounce any fast-changing value in React applications. The main purpose is to limit the rate at which a function gets invoked. This is particularly useful for performance optimization in scenarios such as search input fields, where you might want to wait for a pause in typing before sending a request to a server.

What are use-debounce's main functionalities?

useDebounce

This hook allows you to debounce any fast-changing value. The first parameter is the value to debounce, and the second parameter is the delay in milliseconds.

import { useDebounce } from 'use-debounce';
const [value] = useDebounce(text, 1000);

useDebouncedCallback

This hook gives you a debounced function that you can call. It will only invoke the provided function after the specified delay has elapsed since the last call.

import { useDebouncedCallback } from 'use-debounce';
const [debouncedCallback] = useDebouncedCallback(
  () => {
    // function to be debounced
  },
  1000
);

useThrottledCallback

Similar to debouncing, throttling is another rate-limiting technique. This hook provides a throttled function that will only allow one execution per specified time frame.

import { useThrottledCallback } from 'use-debounce';
const [throttledCallback] = useThrottledCallback(
  () => {
    // function to be throttled
  },
  1000
);

Other packages similar to use-debounce

Keywords

FAQs

Package last updated on 05 May 2022

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