|
It would be great if it were possible to pass a delay on the URL. This is very useful for searches when the user starts typing but initiates the API call only after a delay, something like this. export type UseDebounceReturn = string;
export function useDebounce(value: string, delay: number = 1000): UseDebounceReturn {
const [debouncedValue, setDebouncedValue] = useState(value);
useEffect(() => {
const handler = setTimeout(() => {
setDebouncedValue(value);
}, delay);
return () => {
clearTimeout(handler);
};
}, [value, delay]);
return debouncedValue;
} |
Answered by
franky47
Jan 7, 2025
Replies: 1 comment 2 replies
|
Yes, debounce support is planned, see #291 & #373. For now you can use the |
2 replies
Answer selected by
franky47
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Yes, debounce support is planned, see #291 & #373. For now you can use the
throttleMsoption to do throttling (it will still emit the first update immediately, then slow down the next ones).