Skip to content

useCounter ​

Category
Utilities

Hook that manages a counter with increment, decrement, reset, and set functionalities

typescript
import { useCounter } from '@siberiacancode/reactuse';

Usage ​

typescript
const { count, dec, inc, reset, set } = useCounter(5);

Demo ​

Api ​

Parameters

NameTypeDefaultNote
initialValue?number0The initial number value
options.min?numberNumber.NEGATIVE_INFINITYThe min of count value
options.max?numberNumber.POSITIVE_INFINITYThe max of count value

Parameters

NameTypeDefaultNote
params.initialValue?number0The initial number value
params.min?numberNumber.NEGATIVE_INFINITYThe min of count value
params.max?numberNumber.POSITIVE_INFINITYThe max of count value

Contributors ​

Source • Demo