useCounter

A powerful hook that provides counting logic with bounds and step increments.

Live Demo
0
Bounded: [-10, 10]
Usage Example
1import { useCounter } from '@danixsoft/hooks';
2
3function Counter() {
4  const { count, increment, decrement, reset } = useCounter(0, {
5    min: -10,
6    max: 10,
7  });
8
9  return (
10    <div>
11      <p>Count: {count}</p>
12      <button onClick={increment}>Increment</button>
13      <button onClick={decrement}>Decrement</button>
14      <button onClick={reset}>Reset</button>
15    </div>
16  );
17}