useCounter
Custom hook that manages a counter with increment, decrement, reset, and setCount functionalities.
Installation
npx sse-hooks add use-counter
yarn dlx sse-hooks add use-counter
pnpm dlx sse-hooks add use-counter
deno run -A npm:sse-hooks add use-counter
bunx sse-hooks add use-counter
Usage
example.ts
import { useCounter } from "./{hooks file}";
const { count, increment, decrement, reset, setCount } = useCounter(5);
API
Parameters
| Prop | Default | Type |
|---|---|---|
initialValue | - |
The initial value for the counter. |
Returns
| Return Value | Default | Type |
|---|---|---|
count | - |
The current count value. |
decrement | - |
Function to decrement the counter by 1. |
increment | - |
Function to increment the counter by 1. |
reset | - |
Function to reset the counter to its initial value. |
setCount | - |
Function to set a specific value to the counter. |
Types Aliases
No specific type aliases defined for this component.