All Projects → LobsterBandit → use-countdown-timer

LobsterBandit / use-countdown-timer

Licence: MIT license
React hook exposing a countdown timer with optional expiration reset callbacks

Programming Languages

typescript
32286 projects
HTML
75241 projects
javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to use-countdown-timer

React Countdown
React Component showing a countdown to certain date and time.
Stars: ✭ 58 (+87.1%)
Mutual labels:  countdown, timer
React Timer Hook
React timer hook
Stars: ✭ 118 (+280.65%)
Mutual labels:  countdown, timer
Countdowntask
⌛️A countdown library for Android.
Stars: ✭ 64 (+106.45%)
Mutual labels:  countdown, timer
Easytimer.js
Easy to use Timer/Stopwatch/Countdown library compatible with AMD, ES6 and Typescript
Stars: ✭ 562 (+1712.9%)
Mutual labels:  countdown, timer
react-use-countdown
React hook for countdown state.
Stars: ✭ 19 (-38.71%)
Mutual labels:  countdown, react-hooks
Countdownlabel
Simple countdown UILabel with morphing animation, and some useful function.
Stars: ✭ 714 (+2203.23%)
Mutual labels:  countdown, timer
Use Timer
A timer hook for React
Stars: ✭ 113 (+264.52%)
Mutual labels:  countdown, timer
Flip Clock
A flip clock, timer and countdown made with Polymer
Stars: ✭ 69 (+122.58%)
Mutual labels:  countdown, timer
React Countdown Circle Timer
Lightweight React/React Native countdown timer component with color and progress animation based on SVG
Stars: ✭ 220 (+609.68%)
Mutual labels:  countdown, timer
React Native Countdown Component
React Native CountDown
Stars: ✭ 193 (+522.58%)
Mutual labels:  countdown, timer
Web-Time-Tracker
Plugin named Timetracker is a time counter that works in both increase and decrease directions.
Stars: ✭ 21 (-32.26%)
Mutual labels:  countdown, timer
react-timer-wrapper
Composable React Timer component that passes status props to children, in addition to some basic callbacks. Can be used at a countdown timer ⏲ or as stopwatch ⏱ to track time while active.
Stars: ✭ 14 (-54.84%)
Mutual labels:  countdown, timer
react-component-countdown-timer
This is a simple count down timer react component.
Stars: ✭ 18 (-41.94%)
Mutual labels:  countdown, timer
Termdown
Countdown timer and stopwatch in your terminal
Stars: ✭ 749 (+2316.13%)
Mutual labels:  countdown, timer
alfred-timer-workflow
Alfred workflow to start a timer, which blinks when the time is up.
Stars: ✭ 39 (+25.81%)
Mutual labels:  countdown, timer
Flipdown
⏰ A lightweight and performant flip styled countdown clock
Stars: ✭ 136 (+338.71%)
Mutual labels:  countdown, timer
CountdownTimer-TeLeTiPs
The very first powerful Telegram bot to countdown to your important events in any group chat. Live countdown timer (days : hours : minutes : seconds)
Stars: ✭ 122 (+293.55%)
Mutual labels:  countdown, timer
tiny-timer
🕑 Small countdown timer and stopwatch module.
Stars: ✭ 39 (+25.81%)
Mutual labels:  countdown, timer
mint-ui
Design System | React UI components for web
Stars: ✭ 17 (-45.16%)
Mutual labels:  react-hooks
rapid-react
A light weight interactive CLI Automation Tool 🛠️ for rapid scaffolding of tailored React apps with Create React App under the hood.
Stars: ✭ 73 (+135.48%)
Mutual labels:  react-hooks

use-countdown-timer

React hook exposing a countdown timer with optional expiration and reset callbacks

CI NPM downloads Bundlephobia Coverage Status

Install

npm install --save use-countdown-timer

Parameters and Return Types

use-countdown-timer is written in TypeScript and bundles type definitions.

export interface ICountdownTimerParams {
  timer: number;
  interval?: number;
  autostart?: boolean;
  expireImmediate?: boolean;
  onExpire?: () => void;
  onReset?: () => void;
}

export declare type CountdownTimerResults = {
  countdown: number;
  isRunning: boolean;
  start: () => void;
  reset: () => void;
  pause: () => void;
};

Usage

import React from 'react';

import { useCountdownTimer } from 'use-countdown-timer';

const Example = () => {
  const { countdown, start, reset, pause, isRunning } = useCountdownTimer({
    timer: 1000 * 5,
  });

  return (
    <React.Fragment>
      <div>{countdown}</div>
      <button onClick={reset}>Reset</button>
      {isRunning ? (
        <button onClick={pause}>Pause</button>
      ) : (
        <button onClick={start}>Start</button>
      )}
    </React.Fragment>
  );
};

Development

Local development involves two parts.

First, install and start the library so that it watches src/ directory and automatically recompiles to dist/ on change.

# clone the repo
git clone https://github.com/LobsterBandit/use-countdown-timer.git

# install dependencies
cd use-countdown-timer/
npm install

# start rollup in watch mode
npm start

Second, install and start the example app that is linked to your local use-countdown-timer version.

# in second terminal window
cd example/
npm install

# start create-react-app dev server
npm start

Now, any changes to src/ in the local use-countdown-timer or to the example app's example/src/ will live-reload the dev server.

License

MIT © LobsterBandit


This hook is created using create-react-hook.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].