fn
useCounter
v0.0.1testeddemoA composable that provides a counter with increment, decrement, set, get, and reset functions
Examples
ts
const { count, increment } = useCounter(0);ts
const { count, increment, decrement, set, get, reset } = useCounter(0, { min: 0, max: 10 });Demo
Loading demo…
Signature
ts
export function useCounter(
initialValue: MaybeRefOrGetter<number> = 0,
options: UseCounterOptions ={ ... }Parameters
| Parameter | Type | Description |
|---|---|---|
initialValue? | MaybeRefOrGetter<number> | The initial value of the counter |
options? | UseCounterOptions | The options for the counter |
Returns
UseConterReturnThe counter object