Skip to main content

useDebounce

React hooks that debounce value

Usage

Live Editor
function Demo() {
  const [value, setValue] = useState<string>("");
  const debouncedValue = useDebounce(value, 500);

  return (
    <div>
      <input
        value={value}
        onChange={e => setValue(e.target.value)}
        placeholder="Typed value"
        style={{ width: 280 }}
      />
      <p style={{ marginTop: 16 }}>DebouncedValue: {debouncedValue}</p>
    </div>
  );
};

Result
Loading...

API

useDebounce

Returns

T

Arguments

ArgumentDescriptionTypeDefaultValue
valuethe value need to debounceT (Required)-
waitwait timenumber | undefined-
optionsoptions passed to lodash.debounce_.DebounceSettings | undefined-