useThrottle

React hooks that throttle value.

Usage

import { useThrottle } from "@reactuses/core";

const Demo = () => {
  const [value, setValue] = useState<string>();
  const throttledValue = useThrottle(value, 500);

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

Example

throttledValue:

Type Declarations

export default function useThrottle<T>(
  value: T,
  wait?: number,
  options?: ThrottleSettings
): T