Download src/hooks/use-debounce.ts from SaylorTwift/openhands: direct link, hf CLI and curl.
- Browser
- Download file 351 Bytes
-
https://huggingface.co/SaylorTwift/openhands/resolve/main/src/hooks/use-debounce.ts
- Command line
-
hf download hf://SaylorTwift/openhands/src/hooks/use-debounce.ts
-
curl -L -o use-debounce.ts https://huggingface.co/SaylorTwift/openhands/resolve/main/src/hooks/use-debounce.ts
351 Bytes
| import { useEffect, useState } from "react"; | |
| export function useDebounce<T>(value: T, delay: number): T { | |
| const [debouncedValue, setDebouncedValue] = useState<T>(value); | |
| useEffect(() => { | |
| const timer = setTimeout(() => setDebouncedValue(value), delay); | |
| return () => clearTimeout(timer); | |
| }, [value, delay]); | |
| return debouncedValue; | |
| } | |