You're Invited: Meet the Socket team at BSidesSF and RSAC - April 27 - May 1.RSVP
Socket
Sign inDemoInstall
Socket

use-debouncy

Package Overview
Dependencies
Maintainers
1
Versions
49
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

use-debouncy

🌀Small (120 bytes) debounce effect hook for React with TypeScript support

2.0.1
Source
npm
Version published
Maintainers
1
Created
Source

useDebouncy

🌀Small (120 bytes) debounce effect hook for React with TypeScript support

license dependents types codecov

Features

  • 👌 No dependencies.
  • 🏋️‍ Tiny. 120 bytes. Size Limit controls the size.
  • 📖 Types. Support TypeScript.
  • 🎣 Easy. Like useEffect hook.

Installation

# NPM
npm install use-debouncy

# YARN
yarn add use-debouncy

Examples

Demo codesandbox

import React, { useState } from 'react';
import useDebouncy from 'use-debouncy';

const App = () => {
  const [value, setValue] = useState('');

  useDebouncy(
    () => fetchData(value), // function debounce
    400, // number of milliseconds to delay
    [value], // array values that the debounce depends (like as useEffect)
  );

  return (
    <input value={value} onChange={(event) => setValue(event.target.value)} />
  );
};

API Reference

useDebouncy

function useDebouncy(
  fn: () => void | (() => void | undefined),
  wait?: number,
  deps?: any[],
): void;
PropRequiredDefaultDescription
fnDebounce callback.
wait0Number of milliseconds to delay.
deps[]Array values that the debounce depends (like as useEffect).

Keywords

debounce

FAQs

Package last updated on 02 Jul 2020

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