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

@quiqupltd/react-time-provider

Package Overview
Dependencies
Maintainers
24
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@quiqupltd/react-time-provider

A configurable timer utility to pass time props to your components via Context API at a set interval.

  • 0.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
12
increased by1100%
Maintainers
24
Weekly downloads
 
Created
Source

React TimeProvider and TimeConsumer

NPM Build Status Test Coverage JavaScript Style Guide Documentation Status

A configurable timer utility to pass time props to your components via Context API at a set interval.

Install

yarn add @quiqupltd/react-time-provider

Use

import React, { Component } from 'react'
import TimeProvider from '@quiqupltd/react-time-provider'

class App extends Component {
  render() {
    return (
      <TimeProvider isTimerRunning={true}>
        <Routes />
      </TimeProvider>
    )
  }
}

Then consume in your app

import { TimeConsumer } from '@quiqupltd/react-time-provider'

const RemainingTime = () => {
  return (
    <TimeConsumer>
      { ({now}) => <ComponentThatNeedsTimer now={now}/> }
    </TimeConsumer>
  )
}

TimeProvider

propTypeDescriptionDefault
nowNumberUNIX timestamp ie. 1523444679818Date.now()
isTimerRunningBooleantrue or false starts or stops the timerfalse
timerIntervalNumberinterval length in milliseconds1000

TimeConsumer

Children of TimeConsumer will have access to TimeProvider's props via render props

License

MIT © QuiqupQuiqup

FAQs

Package last updated on 21 Apr 2018

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