Hooks
useCounter
A hook that returns a counter value and a function to increment or decrement the counter.
useCounter
A hook that returns a counter value and a function to increment or decrement the counter.
Usage
API
useCounter
Returns a counter value and a function to increment or decrement the counter.
Parameters
Name | Type | Description |
---|---|---|
initialValue | number | The initial value of the counter. Default is 0 . |
Returns
Name | Type | Description |
---|---|---|
count | number | The current value of the counter. |
increment | () => void | A function to increment the counter. |
decrement | () => void | A function to decrement the counter. |
reset | () => void | A function to reset the counter. |
setCount | Dispatch | A state setter function. |