useCounter
Returns a tuple with counter value and increment, decrement, reset functions.
useCounter
Installation
Usage
API
useCounter
Returns a tuple with counter value and increment, decrement, reset functions.
Parameters
| Name | Type | Description |
|---|---|---|
| initialValue? | number | Optional initial value of the counter. Defaults to 0. |
Returns
| Name | Type | Description |
|---|---|---|
| count | number | The current value of the counter. |
| increment | () => void | A function to increment the counter by 1. |
| decrement | () => void | A function to decrement the counter by 1. |
| reset | () => void | A function to reset the counter to the initial value. |
| setCount | Dispatch | A function to set the counter to a new value. |