useThrottledMemo
hookas/use-throttled-memoFreeHook
A hook to throttle a memo
Install it
npx shadcn@latest add https://hookas.letstri.dev/r/use-throttled-memo.jsonSource
1'use client'23import * as React from 'react'4import { useThrottledCallback } from './use-throttled-callback'56export function useThrottledMemo<T>(factory: () => T, deps: React.DependencyList, delay: number) {7 const [state, setState] = React.useState<T>(() => factory())89 const throttledSetState = useThrottledCallback((value: T) => {10 setState(value)11 }, [setState], delay)1213 React.useEffect(() => {14 throttledSetState(factory())15 }, [...deps, throttledSetState])1617 return state18}
What it pulls in
Other registry items
Files it writes
More from hookas
All 30 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| useAsyncEffectuse-async-effect | hookas | Hooks | Free | no deps | |
| useClickOutsideuse-click-outside | hookas | Hooks | Free | no deps | |
| useDebounceCallbackuse-debounced-callback | hookas | Hooks | Free | no deps | |
| useDebounceMemouse-debounced-memo | hookas | Hooks | Free | no deps | |
| useDebounceStateuse-debounced-state | hookas | Hooks | Free | no deps | |
| useElementSizeuse-element-size | hookas | Hooks | Free | no deps | |
| useFullscreenuse-fullscreen | hookas | Hooks | Free | no deps | |
| useIntervaluse-interval | hookas | Hooks | Free | no deps |
