
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.
@noeg/usedebounce
Advanced tools
A collection of React hooks for debouncing values and functions to optimize performance and limit the rate of executions.
npm install @noeg/usedebounce
# or
yarn add @noeg/usedebounce
# or
pnpm add @noeg/usedebounce
Use this hook when you want to debounce a value that changes frequently (e.g., search input, form fields).
import { useDebounceValue } from '@noeg/usedebounce'
function SearchComponent() {
const [searchTerm, setSearchTerm] = useState('')
const debouncedSearchTerm = useDebounceValue(searchTerm, 500)
useEffect(() => {
// This effect will only run 500ms after the last searchTerm change
console.log('Searching for:', debouncedSearchTerm)
}, [debouncedSearchTerm])
return (
<input
type="text"
value={searchTerm}
onChange={(e) => setSearchTerm(e.target.value)}
/>
)
}
Use this hook when you want to debounce a function that gets called frequently (e.g., event handlers, API calls).
import { useDebounceFunction } from '@noeg/usedebounce'
function AutosaveForm() {
const save = async (data: FormData) => {
await api.save(data)
}
// Create a debounced version of the save function
const debouncedSave = useDebounceFunction(save, 1000)
return (
<form
onChange={(e) => {
const data = new FormData(e.currentTarget)
// This will only call save() once, 1000ms after the last change
debouncedSave(data)
}}
>
{/* form fields */}
</form>
)
}
function useDebounceValue<T>(value: T, delay: number): T
| Parameter | Type | Description |
|---|---|---|
value | T | The value to debounce |
delay | number | The delay in milliseconds |
Returns the debounced value of type T.
function useDebounceFunction<T extends (...args: any[]) => any>(
fn: T,
delay: number
): (...args: Parameters<T>) => void
| Parameter | Type | Description |
|---|---|---|
fn | T | The function to debounce |
delay | number | The delay in milliseconds |
Returns a debounced version of the provided function that:
For backward compatibility, the default export is an alias for useDebounceValue:
import { useDebounce } from '@noeg/usedebounce'
// useDebounce is the same as useDebounceValue
MIT
Contributions are welcome! Please feel free to submit a Pull Request.
FAQs
React hooks for debouncing value or function calls
We found that @noeg/usedebounce 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.