React Hooks
    Preparing search index...

    Function useCounter

    • A React hook to manage a numeric counter with min/max boundaries, step increments, and change callbacks

      Parameters

      Returns CounterReturn

      An object containing the counter state, controls, and helper flags

      This hook uses React hooks internally:

      • useState - to manage the counter state
      • useCallback - to memoize increment, decrement, reset, and resetTo functions
      • useEffect - to call onChange whenever the counter changes
      const counter = useCounter({ initialValue: 5, min: 0, max: 10, step: 2 });
      counter.increment(); // increases by 2
      counter.decrement(); // decreases by 2
      counter.reset(); // resets to 5
      counter.resetTo(8); // resets to 8

      0.1.0