• A throttled version of React's useState that limits how often the state is updated.

    When setValue is called repeatedly, the state will update immediately if enough time has passed since the last update. Otherwise, it schedules an update after the remaining throttle interval. The most recent value is always applied eventually (trailing flush).

    Type Parameters

    • T

    Parameters

    • initialValue: T

      The initial state value.

    • intervalMs: number

      The minimum interval (in milliseconds) between state updates.

    Returns [T, ((value, forced?) => void)]

    A tuple of [state, setValue], just like useState.