Gathering detailed insights and metrics for @react-hook/debounce
Gathering detailed insights and metrics for @react-hook/debounce
Gathering detailed insights and metrics for @react-hook/debounce
Gathering detailed insights and metrics for @react-hook/debounce
use-debounce
Debounce hook for react
use-debouncy
🌀 Small (~0.2kb) debounce effect hook for React with TypeScript support
react-debounce-hook
A react hook for using a debouncing an input with state variables In react.
@huse/debounce
--- title: README nav: title: Hooks path: /hook group: title: Debounce path: /debounce order: 1 ---
↩ Strongly typed, concurrent mode-safe React hooks
npm install @react-hook/debounce
Typescript
Module System
97.9
Supply Chain
99
Quality
76
Maintenance
100
Vulnerability
100
License
TypeScript (85.29%)
JavaScript (14.55%)
Shell (0.17%)
Total Downloads
27,743,846
Last Day
8,634
Last Week
192,208
Last Month
868,335
Last Year
9,454,608
MIT License
1,513 Stars
429 Commits
96 Forks
9 Watchers
14 Branches
27 Contributors
Updated on Jul 05, 2025
Minified
Minified + Gzipped
Latest Version
4.0.0
Package Id
@react-hook/debounce@4.0.0
Size
8.58 kB
Published on
Jun 18, 2021
Cumulative downloads
Total Downloads
Last Day
-3.4%
8,634
Compared to previous day
Last Week
-9.5%
192,208
Compared to previous week
Last Month
-1.5%
868,335
Compared to previous month
Last Year
28.5%
9,454,608
Compared to previous year
1
1
npm i @react-hook/debounce
A React hook for debouncing setState and other callbacks
1import {useDebounce, useDebounceCallback} from '@react-hook/debounce' 2 3const Component = (props) => { 4 // at a basic level, used just like useState 5 const [value, setValue] = useDebounce('initialValue') 6} 7 8const useMyCallback = (initialState, wait, leading) => { 9 // this is the same code useDebounce() uses to debounce setState 10 const [state, setState] = useState(initialState) 11 return [state, useDebounceCallback(setState, wait, leading)] 12}
A hook that acts just like React.useState
, but with a setState
function
that is only invoked after the wait
time in ms
has been exceeded between
calls.
1export const useDebounce = <State>( 2 initialState: State | (() => State), 3 wait?: number, 4 leading?: boolean 5): [State, Dispatch<SetStateAction<State>>]
Property | Type | Default | Description |
---|---|---|---|
initialState | State | (() => State) | The initial state provided to React.useState | |
wait | number | 100 | The amount of time in ms you want to wait after the latest call before setting a new state. |
leading | boolean | false | Calls setState on the leading edge (right away). When false , setState will not be called until the next frame is due |
[state, setStateDebounced, setStateImmediate]
Variable | Type | Description |
---|---|---|
state | State | The current value in state |
setStateDebounced | Function | A debounced setState callback |
setStateImmediate | Function | The regular, immediate setState callback |
Note: Using setStateImmediate
does not cancel a queued setStateDebounced
calls,
i.e., the setStateDebounced
will still take effect once its wait time is over.
If needed, cancelling behavior could typically still be achieved by calling both
setStateImmediate
and setStateDebounced
with the same value.
A hook that will invoke its callback only after wait
time in ms
has been
exceeded between calls.
1export const useDebounceCallback = <CallbackArgs extends any[]>( 2 callback: (...args: CallbackArgs) => void, 3 wait = 100, 4 leading = false 5): ((...args: CallbackArgs) => void)
Property | Type | Default | Description |
---|---|---|---|
callback | (...args: CallbackArgs) => void | This is the callback you want to debounce. You need to wrap closures/unstable callbacks in useCallback() so that they are stable, otherwise throttling will break between renders. | |
wait | number | 100 | Defines the amount of time you want setState to wait after the last received action before executing |
leading | boolean | false | Calls setState on the leading edge (right away). When false , setState will not be called until the next frame is due |
debouncedCallback
Variable | Type | Description |
---|---|---|
debouncedCallback | (...args: CallbackArgs) => void | A debounced version of your callback |
MIT
No vulnerabilities found.
Reason
license file detected
Details
Reason
no binaries found in the repo
Reason
Found 14/28 approved changesets -- score normalized to 5
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
37 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-06-30
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More