use-countdown-time
TypeScript icon, indicating that this package has built-in type declarations

0.0.4 • Public • Published

use-countdown-time

React hook Timer with Forward Backword direction.

NPM

Install

yarn add use-countdown-time

Usage

import React from 'react'
import useTimer, { FORWARD, BACKWARD } from "use-countdown-time";
 
function Timer() {
  const duration = 60 * 60 * 24 * 7 * 2;
  const timerOptions = {
    direction: BACKWARD,
    durationStep: 1,
    durationInterval: 1000
  };
 
  const { weeks, days, hours, minutes, seconds, isDone } = useTimer(
    duration,
    timerOptions
  );
  return (
    <div className="App">
      {!isDone ? (
        <div>
          Now {weeks}: {days}: {hours}:{minutes}:{seconds} times left{" "}
        </div>
      ) : (
        "Time Up"
      )}{" "}
    </div>
  );
}

License

MIT © chirag

Readme

Keywords

none

Package Sidebar

Install

npm i use-countdown-time

Weekly Downloads

0

Version

0.0.4

License

MIT

Unpacked Size

14.8 kB

Total Files

18

Last publish

Collaborators

  • chirag.3092