Skip to main content
Version: 7.3

useDebounce()

function useDebounce<T>(value: T, delay: number, updatable?: boolean): T;

Delays updating the parameters by debouncing. Useful to avoid spamming network requests when parameters might change quickly (like a typeahead field).

import { useDebounce } from '@rest-hooks/hooks';
import { useSuspense } from '@rest-hooks/react';

const debouncedFilter = useDebounce(filter, 200);
const data = useSuspense(MyEndpoint, { filter: debouncedFilter });

Part of @rest-hooks/hooks