React Hooks
    Preparing search index...

    Interface CounterReturn

    Return type of useCounter hook

    interface CounterReturn {
        count: number;
        setCount: Dispatch<SetStateAction<number>>;
        increment: () => void;
        decrement: () => void;
        reset: () => void;
        resetTo: (value: number) => void;
        isMin: boolean;
        isMax: boolean;
        setCountBounded: Dispatch<SetStateAction<number>>;
    }
    Index

    Properties

    count: number

    Current counter value

    setCount: Dispatch<SetStateAction<number>>

    Set counter value directly (does NOT respect min and max)

    increment: () => void

    Increment the counter by step, respecting max

    decrement: () => void

    Decrement the counter by step, respecting min

    reset: () => void

    Reset counter to the initial value, respecting min/max

    resetTo: (value: number) => void

    Reset counter to a specific value, respecting min/max

    Type Declaration

      • (value: number): void
      • Parameters

        • value: number

          The value to reset the counter

        Returns void

    isMin: boolean

    Boolean indicating if the counter is at its minimum value

    isMax: boolean

    Boolean indicating if the counter is at its maximum value

    setCountBounded: Dispatch<SetStateAction<number>>

    Sets the counter value directly while enforcing min and max boundaries

    Accepts either a number or an updater function (prev) => next