@reactivers/hooks Github link@reactivers/hooks NPM link

useCounter

Introduction

  • useCounter is a simple counter hook.
  • You can use counter hook for many purposes easily and quickly.
const { 
    counter, 
    increase, 
    decrease, 
    setCounter, 
    reset 
    } = useCounter();

Getting Started

  • This hook is simple counter hook. You may want to use this for a quick usage.
  • You need to import useCounter.

From Collection

import { useCounter} from "@reactivers/hooks";

From Package

import { useCounter} from "@reactivers/use-counter";

Interfaces

Props

interface CounterProps {
    initial?: number; // Default = 0
}

Returns

interface IUseCounter {
    increase: (by?: number) => void; // by = 1
    decrease: (by?: number) => void; // by = 1
    reset: () => void;
    setCounter: (counter: number) => void;
    counter: number
}

Example

Example Preview - CodeSandbox