1.1.19 • Published 4 years ago

react-debounce-hook v1.1.19

Weekly downloads
695
License
Apache-2.0
Repository
github
Last release
4 years ago

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.

1.1.19

4 years ago

1.1.18

5 years ago

1.1.17

5 years ago

1.1.16

5 years ago

1.1.15

5 years ago

1.1.14

5 years ago

1.1.13

5 years ago

1.1.12

5 years ago

1.1.11

5 years ago

1.1.10

5 years ago

1.1.9

5 years ago

1.1.8

5 years ago

1.1.7

5 years ago

1.1.6

5 years ago

1.1.5

5 years ago

1.1.4

5 years ago

1.1.3

5 years ago

1.1.2

5 years ago

1.1.1

5 years ago

1.1.0

5 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago