MCPcopy Create free account
hub / github.com/R44VC0RP/opencode.cafe / useDebounce

Function useDebounce

app/submit/page.tsx:30–44  ·  view source on GitHub ↗
(value: T, delay: number)

Source from the content-addressed store, hash-verified

28
29// Custom hook for debouncing a value
30function useDebounce<T>(value: T, delay: number): T {
31 const [debouncedValue, setDebouncedValue] = useState<T>(value)
32
33 useEffect(() => {
34 const handler = setTimeout(() => {
35 setDebouncedValue(value)
36 }, delay)
37
38 return () => {
39 clearTimeout(handler)
40 }
41 }, [value, delay])
42
43 return debouncedValue
44}
45
46interface FormData {
47 type: string

Callers 1

SubmitFormFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected