Latest Threat Research:SANDWORM_MODE: Shai-Hulud-Style npm Worm Hijacks CI Workflows and Poisons AI Toolchains.Details
Socket
Book a DemoInstallSign in
Socket

re-use-debounce

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

re-use-debounce

Reuse lodash debounce as React hook

latest
Source
npmnpm
Version
0.0.1
Version published
Maintainers
1
Created
Source

re-use-debounce Build Status

Reuse lodash debounce as React hook

Install

$ npm install re-use-debounce

Note: This libaray expects that you already depend on lodash 4.

Usage

import React from 'react';
import useDebounce from 're-use-debounce';

function MyComponent(props) {
  const [value, setValue] = React.useState('');

  const [debouncedValue, setDebouncedValue] = React.useState('');
  useDebounce(value, setDebouncedValue, 300);

  React.useEffect(() => {
    console.log(`debouncedValue: ${debouncedValue}`);
  }, [debouncedValue])

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

API

useDebounce(input, onChange, delay, [options])

input

Type: any

The value that is being debounced

onChange

Type: function

The function to debounce

delay

Type: number

The number of milliseconds to debounce

options

Type: Object

leading

Type: boolean
Default: false

Specify invoking on the leading edge of the timeout.

trailing

Type: boolean
Default: true

Specify invoking on the trailing edge of the timeout.

maxWait

Type: number
Default: undefined

The maximum time onChange is allowed to be delayed before it's invoked.

License

MIT © Sindre Seppola

Keywords

React

FAQs

Package last updated on 24 Mar 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