useCounter
Custom hook that manages a counter with increment, decrement, reset, and setCount functionalities.
Installation
npx sse-tool add use-counter
npm install sse-hooks
Usage
import { useCounter } from "./{hooks file}";
const { count, increment, decrement, reset, setCount } = useCounter(5);
import { useCounter } from "sse-hooks";
const { count, increment, decrement, reset, setCount } = useCounter(5);
API
Parameters
| Name | Type | Description |
|---|---|---|
| initialValue | number | The initial value for the counter. |
Return Value
Returns UseCounterReturn.
An object containing the current count and functions to interact with the counter.