1.1.7 • Published 3 years ago

@rafcin/counter v1.1.7

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

Counter

A React hook that provides simple and advance counter functionalities. Mostly used to create numeric inputs and countdown timers.

Installation

yarn add @rafcin/counter

# or

npm i @rafcin/counter

Import hook

import { useCounter } from "@rafcin/counter"

Basic usage

export function Example() {
  const counter = useCounter({
    max: 10,
    min: 0,
    step: 0.1,
  })

  return (
    <div>
      <button onClick={() => counter.increment()}>Increment</button>
      <p>{counter.value}</p>
      <button onClick={() => counter.decrement()}>Decrement</button>
    </div>
  )
}