Installations
npm install use-lodash-debounce
Developer Guide
Typescript
No
Module System
CommonJS
Min. Node Version
>=8
Node Version
14.16.0
NPM Version
6.14.11
Score
72.8
Supply Chain
92.2
Quality
75
Maintenance
100
Vulnerability
99.6
License
Releases
Unable to fetch releases
Contributors
Unable to fetch Contributors
Languages
TypeScript (77.41%)
JavaScript (22.59%)
Developer
gnbaron
Download Statistics
Total Downloads
1,000,574
Last Day
165
Last Week
990
Last Month
9,314
Last Year
131,951
GitHub Statistics
55 Stars
42 Commits
6 Forks
1 Watching
6 Branches
4 Contributors
Bundle Size
701.00 B
Minified
362.00 B
Minified + Gzipped
Package Meta Information
Latest Version
1.3.0
Package Id
use-lodash-debounce@1.3.0
Unpacked Size
11.13 kB
Size
3.63 kB
File Count
8
NPM Version
6.14.11
Node Version
14.16.0
Total Downloads
Cumulative downloads
Total Downloads
1,000,574
Last day
3.1%
165
Compared to previous day
Last week
-50%
990
Compared to previous week
Last month
-13.6%
9,314
Compared to previous month
Last year
-51%
131,951
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Peer Dependencies
2
Dev Dependencies
20
use-lodash-debounce ⏳
Custom react hooks for lodash debounce that provides an easy way to debounce any value, debounced callbacks and types out of the box.
Install
Using yarn or npm:
1yarn add use-lodash-debounce
1npm i use-lodash-debounce
⚠️ react@16.8.0
or greater is required due to the usage of hooks.
Notice that react
and lodash.debounce
are defined as peer dependencies in order to get a smaller bundle size. This means they should be installed in your project.
Usage
Debounce values throughout re-renders with useDebounce
. The debounce will be triggered everytime the value changes (compared using strict equality).
1import { useDebounce } from 'use-lodash-debounce' 2 3const [value, setValue] = useState() 4const debouncedValue = useDebounce(value, 800)
Create debounced callbacks with useDebouncedCallback
.
1import { useDebouncedCallback } from 'use-lodash-debounce' 2 3const [value, setValue] = useState() 4const debouncedSetValue = useDebouncedCallback(setValue, 800)
Example
1import { useDebounce } from 'use-lodash-debounce' 2 3function SearchInput() { 4 const [value, setValue] = useState(); 5 const debouncedValue = useDebounce(value, 1000); 6 7 useEffect(() => { 8 // do search stuff 9 }, [debouncedValue]); 10 11 return ( 12 <input 13 placeholder="Type to search" 14 onChange={e => setValue(e.target.value)} 15 /> 16 ); 17}
Debounce Options
Lodash debounce supports a set of additional options which can be provided through a third parameter for useDebounce
and useDebouncedCallback
.
1const options = { leading: true, maxWait: 1600, trailing: false } 2const debouncedSetValue = useDebouncedCallback(setValue, 800, options)
See lodash debounce docs for details.
Cancel / Flush
The callback returned by useDebouncedCallback
has a method cancel
to cancel delayed function invocations and a flush
method to immediately invoke them.
Alternatives
If you're looking for a debounce hook that don't use lodash internally, check out use-debounce.
License
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: MIT License: LICENSE:0
Reason
Found 3/5 approved changesets -- score normalized to 6
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
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'master'
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 28 are checked with a SAST tool
Reason
26 existing vulnerabilities detected
Details
- Warn: Project is vulnerable to: GHSA-67hx-6x53-jw92
- Warn: Project is vulnerable to: GHSA-6chw-6frg-f759
- Warn: Project is vulnerable to: GHSA-v88g-cgmw-v5xw
- Warn: Project is vulnerable to: GHSA-93q8-gq69-wqmw
- Warn: Project is vulnerable to: GHSA-cwfw-4gq5-mrqx
- Warn: Project is vulnerable to: GHSA-g95f-p29q-9xw4
- Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg
- Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275
- Warn: Project is vulnerable to: GHSA-gxpj-cx7g-858c
- Warn: Project is vulnerable to: GHSA-w573-4hg7-7wgq
- Warn: Project is vulnerable to: GHSA-8r6j-v8pm-fqw3
- Warn: Project is vulnerable to: MAL-2023-462
- Warn: Project is vulnerable to: GHSA-896r-f27r-55mw
- Warn: Project is vulnerable to: GHSA-9c47-m6qq-7p4h
- Warn: Project is vulnerable to: GHSA-6c8f-qphg-qjgp
- Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv
- Warn: Project is vulnerable to: GHSA-f8q6-p94x-37v3
- Warn: Project is vulnerable to: GHSA-xvch-5gv4-984h
- Warn: Project is vulnerable to: GHSA-5fw9-fq32-wv5p
- Warn: Project is vulnerable to: GHSA-hrpp-h998-j3pp
- Warn: Project is vulnerable to: GHSA-p8p7-x288-28g6
- Warn: Project is vulnerable to: GHSA-gcx4-mw62-g8wm
- Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw
- Warn: Project is vulnerable to: GHSA-f5x3-32g6-xq36
- Warn: Project is vulnerable to: GHSA-72xf-g2v4-qvf3
- Warn: Project is vulnerable to: GHSA-3h5v-q93c-6h6q
Score
2.5
/10
Last Scanned on 2025-01-06
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