All Projects → ryanhefner → react-timer-wrapper

ryanhefner / react-timer-wrapper

Licence: MIT license
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.

Programming Languages

javascript
184084 projects - #8 most used programming language
CSS
56736 projects
HTML
75241 projects

Projects that are alternatives of or similar to react-timer-wrapper

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 (+771.43%)
Mutual labels:  countdown, timer, countdown-timer
react-component-countdown-timer
This is a simple count down timer react component.
Stars: ✭ 18 (+28.57%)
Mutual labels:  countdown, timer, react-timer
Easytimer.js
Easy to use Timer/Stopwatch/Countdown library compatible with AMD, ES6 and Typescript
Stars: ✭ 562 (+3914.29%)
Mutual labels:  countdown, timer
Countdownlabel
Simple countdown UILabel with morphing animation, and some useful function.
Stars: ✭ 714 (+5000%)
Mutual labels:  countdown, timer
Countdowntask
⌛️A countdown library for Android.
Stars: ✭ 64 (+357.14%)
Mutual labels:  countdown, timer
yii2-time-down-counter
Widget for yii2, to start count down timer with a lot of options, This widget build dependence of timeDownCounter JS library
Stars: ✭ 15 (+7.14%)
Mutual labels:  countdown, countdown-timer
Web-Time-Tracker
Plugin named Timetracker is a time counter that works in both increase and decrease directions.
Stars: ✭ 21 (+50%)
Mutual labels:  countdown, timer
React Countdown
React Component showing a countdown to certain date and time.
Stars: ✭ 58 (+314.29%)
Mutual labels:  countdown, timer
CountdownView
Simple countdown view with custom animations
Stars: ✭ 70 (+400%)
Mutual labels:  countdown, countdown-timer
React Timer Hook
React timer hook
Stars: ✭ 118 (+742.86%)
Mutual labels:  countdown, timer
Use Timer
A timer hook for React
Stars: ✭ 113 (+707.14%)
Mutual labels:  countdown, timer
Flipdown
⏰ A lightweight and performant flip styled countdown clock
Stars: ✭ 136 (+871.43%)
Mutual labels:  countdown, timer
alfred-timer-workflow
Alfred workflow to start a timer, which blinks when the time is up.
Stars: ✭ 39 (+178.57%)
Mutual labels:  countdown, timer
ZXCountDownView
【杀不死的倒计时】一个简单易用的倒计时View,常用于快速创建点击获取验证码按钮,支持各种自定义样式。(特点:重新进入当前页面或重启程序倒计时不会重置,仍将继续执行,且退出程序后的时间也会被自动计算在内)
Stars: ✭ 56 (+300%)
Mutual labels:  countdown, countdown-timer
vue-flip-down
vue 翻页倒计时组件 妙啊
Stars: ✭ 90 (+542.86%)
Mutual labels:  countdown, countdown-timer
Termdown
Countdown timer and stopwatch in your terminal
Stars: ✭ 749 (+5250%)
Mutual labels:  countdown, timer
use-countdown-timer
React hook exposing a countdown timer with optional expiration reset callbacks
Stars: ✭ 31 (+121.43%)
Mutual labels:  countdown, timer
howlonguntilprayuthleaves.com
นับเวลาถอยหลังถึงวันที่พลเอกประยุทธ์ จันทร์โอชา หมดวาระการเป็นนายกรัฐมนตรี
Stars: ✭ 29 (+107.14%)
Mutual labels:  countdown, countdown-timer
Flip Clock
A flip clock, timer and countdown made with Polymer
Stars: ✭ 69 (+392.86%)
Mutual labels:  countdown, timer
React Native Countdown Component
React Native CountDown
Stars: ✭ 193 (+1278.57%)
Mutual labels:  countdown, timer

react-timer-wrapper

npm NPM npm Coveralls github CircleCI Snyk Vulnerabilities for GitHub Repo

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.

Install

Via npm

npm install --save react-timer-wrapper

Via Yarn

yarn add react-timer-wrapper

How to use

The Timer can be used in a couple different ways. You could use it as a standalone timer and setup callbacks to trigger things to happen in your project. Or, wrap child components in Timer component, where those children will receive props passed in by the Timer.

It can be used as a countdown timer, which will fire the onFinish event upon completion. Or, you can use it to track the time that occurs while it’s active.

Properties

  • active:Boolean - Start/stop the timer. (Default: false)
  • component:String | Element - Element or React component used to render/wrap the children. (Default: div)
  • duration:Number - Enables countdown mode and is the number of milliseconds to count before firing onFinish. (Default: 10000)
  • loop:Boolean - Enable looping of the countdown timer. (Default: false)
  • time:Number - Either used as a time offset for the duration when used as a countdown timer, or the initial time to start from when used for tracking time. (Default: 0)
  • onFinish:Function - Callback fired when the timer has finished. (Fired in countdown mode only)
  • onStart:Function - Callback fired when the timer is started.
  • onStop:Function - Callback fired when the timer is stopped.
  • onTimeUpdate:Function - Callback fired when time updates.

Examples

Standalone

import Timer from 'react-timer-wrapper';

...

  onTimerStart({duration, progress, time}) {

  }

  onTimerStop({duration, progress, time}) {

  }

  onTimerTimeUpdate({duration, progress, time}) {

  }

  onTimerFinish({duration, progress, time}) {

  }

  render() {
    const {
      timerActive,
    } = this.state;

    return (
      <Timer
        active={timerActive}
        onFinish={this.onTimerFinish}
        onStart={this.onTimerStart}
        onStop={this.onTimerStop}
        onTimeUpdate={this.onTimerTimeUpdate}
      />
    );
  }

...

With children

import Timer from 'react-timer-wrapper';
import CircleIndicator from 'react-indicators';

...

  render() {
    const {
      timerShouldRun,
    } = this.state;

    return (
      <Timer active={timerShouldRun}>
        <CircleIndicator />
      </Timer>
    );
  }

...

Children

The Timer allows you to easily compose components that provide a visual status of the timer. Each children receives the following props that you can use to communicate the status of the timer.

  • duration:Number - Duration of the countdown timer. (Available for countdown timers only, null passed when used for time tracking)
  • progress:Number - Current percentage of timer complete. (Available for countdown timers only, null passed when used for time tracking)
  • time:Number - Current time on the timer in milliseconds.

Pairs well with...

License

MIT © Ryan Hefner

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].