Hooks

useDebounce

Publisher

cermuel

50 hooks published

More from this publisher

useDebounce

Delay updates to a value until it has stopped changing.

useDebounce.tsx
import { useDebounce } from "@cermuel/hooks/react";import { useState } from "react";export function UseDebounceExample() {  const [query, setQuery] = useState("");  const debouncedQuery = useDebounce(query, 300);  return (    <label>      Search      <input value={query} onChange={(event) => setQuery(event.target.value)} />      <span>Debounced value: {debouncedQuery}</span>    </label>  );}

Props

Param
Type
Default Value
value
T
delay?
number
250

Returns

T