Download client/src/hooks/Input/useDebounce.ts from Zhitomir/chat: direct link, hf CLI and curl.
- Browser
- Download file 404 Bytes
-
https://huggingface.co/spaces/Zhitomir/chat/resolve/main/client/src/hooks/Input/useDebounce.ts
- Command line
-
hf download hf://spaces/Zhitomir/chat/client/src/hooks/Input/useDebounce.ts
-
curl -L -o useDebounce.ts https://huggingface.co/spaces/Zhitomir/chat/resolve/main/client/src/hooks/Input/useDebounce.ts
404 Bytes
| import { useState, useEffect } from 'react'; | |
| function useDebounce(value: string, delay: number) { | |
| const [debouncedValue, setDebouncedValue] = useState(value); | |
| useEffect(() => { | |
| const handler = setTimeout(() => { | |
| setDebouncedValue(value); | |
| }, delay); | |
| return () => { | |
| clearTimeout(handler); | |
| }; | |
| }, [value, delay]); | |
| return debouncedValue; | |
| } | |
| export default useDebounce; | |