import { useDebounceCallback } from "https://deno.land/x/netzo@0.4.72/deps/usehooks-ts.ts";
Hook to create a debounced version of a callback function.
Examples
const debouncedCallback = useDebounceCallback(
(searchTerm) => {
// Perform search after user stops typing for 500 milliseconds
searchApi(searchTerm);
},
500
);
const debouncedCallback = useDebounceCallback( (searchTerm) => { // Perform search after user stops typing for 500 milliseconds searchApi(searchTerm); }, 500 );
// Later in the component debouncedCallback('react hooks'); // Will invoke the callback after 500 milliseconds of inactivity.
Type Parameters
T extends (...args: any) => ReturnType<T>
- Type of the original callback function.
Parameters
func: T
- The callback function to be debounced.
- The delay in milliseconds before the callback is invoked (default is
500
milliseconds).