Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-timer-hoc

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-timer-hoc

A React timer higher-order component

  • 1.0.0
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

React timer component (higher-order)

A React higher-order timer component

Keep your components simple, testable and composable by using higher-order components. This higher-order timer component will re-render your component at the desire rate (in milliseconds).

Demo: http://jsbin.com/vozegataco/edit?html,js,output

Applications

  • Countdowns (time remaining)
  • Timers (time elapsed)
  • Forcing updates / refresh of time-based contents

Installation

npm install --save react-timer-hoc

Usage

Create a new component by wrapping your component with timer HOC. Alongside the properties you specify, the created component will receive a tick property, the specified delay value and a stop function.

import React from 'react';
import ReactDOM from 'react-dom';

function myComponent({ tick, cancel, delay }) {
    return <div>Started { tick * delay }ms ago.</div>
}

const Timer1 = timer(1000)(myComponent);
const Timer2 = timer(2000)(myComponent);

ReactDOM.render(
    <div>
        <Timer1 />
        <Timer2 />
    </div>,
    document.getElementById('app')
);

Keywords

FAQs

Package last updated on 28 Nov 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc