
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
use-lodash-debounce
Advanced tools
Custom react hooks for lodash debounce that provides an easy way to debounce any value, debounced callbacks and types out of the box.
Using yarn or npm:
yarn add use-lodash-debounce
npm 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.
Debounce values throughout re-renders with useDebounce. The debounce will be triggered everytime the value changes (compared using strict equality).
import { useDebounce } from 'use-lodash-debounce'
const [value, setValue] = useState()
const debouncedValue = useDebounce(value, 800)
Create debounced callbacks with useDebouncedCallback.
import { useDebouncedCallback } from 'use-lodash-debounce'
const [value, setValue] = useState()
const debouncedSetValue = useDebouncedCallback(setValue, 800)
import { useDebounce } from 'use-lodash-debounce'
function SearchInput() {
const [value, setValue] = useState();
const debouncedValue = useDebounce(value, 1000);
useEffect(() => {
// do search stuff
}, [debouncedValue]);
return (
<input
placeholder="Type to search"
onChange={e => setValue(e.target.value)}
/>
);
}
Lodash debounce supports a set of additional options which can be provided through a third parameter for useDebounce and useDebouncedCallback.
const options = { leading: true, maxWait: 1600, trailing: false }
const debouncedSetValue = useDebouncedCallback(setValue, 800, options)
See lodash debounce docs for details.
The callback returned by useDebouncedCallback has a method cancel to cancel delayed function invocations and a flush method to immediately invoke them.
If you're looking for a debounce hook that don't use lodash internally, check out use-debounce.
FAQs
Custom react hooks for lodash debounce.
The npm package use-lodash-debounce receives a total of 5,858 weekly downloads. As such, use-lodash-debounce popularity was classified as popular.
We found that use-lodash-debounce demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

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.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.