A React hook to manage a numeric counter with min/max boundaries, step increments, and change callbacks
An object containing the counter state, controls, and helper flags
This hook uses React hooks internally:
onChange
const counter = useCounter({ initialValue: 5, min: 0, max: 10, step: 2 });counter.increment(); // increases by 2counter.decrement(); // decreases by 2counter.reset(); // resets to 5counter.resetTo(8); // resets to 8 Copy
const counter = useCounter({ initialValue: 5, min: 0, max: 10, step: 2 });counter.increment(); // increases by 2counter.decrement(); // decreases by 2counter.reset(); // resets to 5counter.resetTo(8); // resets to 8
0.1.0
A React hook to manage a numeric counter with min/max boundaries, step increments, and change callbacks