use-debounce
shadcn-hooks/use-debounceFreeHook
A hook to debounce a value
Install it
npx shadcn@latest add https://shadcn-hooks.com/r/use-debounce.jsonSource
1import { useEffect, useState } from 'react'2import { useDebounceFn } from '@/registry/hooks/use-debounce-fn'3import type { DebounceOptions } from '@/registry/hooks/use-debounce-fn'45export function useDebounce<T>(6 value: T,7 debounceMs?: number,8 options?: DebounceOptions,9) {10 const [debouncedValue, setDebouncedValue] = useState<T>(value)1112 const { run } = useDebounceFn(13 () => {14 setDebouncedValue(value)15 },16 debounceMs,17 options,18 )1920 useEffect(() => {21 return run()22 }, [value, run])2324 return debouncedValue25}
What it pulls in
Other registry items
Files it writes
More from shadcn-hooks
All 58 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| use-active-elementuse-active-element | shadcn-hooks | Hooks | Free | no deps | |
| use-batteryuse-battery | shadcn-hooks | Hooks | Free | no deps | |
| use-booleanuse-boolean | shadcn-hooks | Hooks | Free | no deps | |
| use-click-any-whereuse-click-any-where | shadcn-hooks | Hooks | Free | no deps | |
| use-click-awayuse-click-away | shadcn-hooks | Hooks | Free | no deps | |
| use-clipboarduse-clipboard | shadcn-hooks | Hooks | Free | no deps | |
| use-controllable-valueuse-controllable-value | shadcn-hooks | Hooks | Free | 1 dep | |
| use-counteruse-counter | shadcn-hooks | Hooks | Free | no deps |
