Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
react-timer-hoc
Advanced tools
Readme
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).
This higher-order component takes care of when to call render on your component, so your component has only to care about the rendering logic.
A higher-order component is just a function that takes an existing component and returns another component that wraps it.
Read about higher-order components here (applies to deku as well): Mixins Are Dead. Long Live Composition.
Demo: http://jsbin.com/nalixa/edit?html,js,output
npm install --save react-timer-hoc
Create a new component by wrapping your component with timer(delay)(Component) HOC. Alongside the properties you specify, the created component will receive a timer
property containing:
tick
value (incremented)delay
valuestop
, resume
and setDelay
functionsImportant notice with ES5
babel 6 changed the way transpiled default exports work. See Babel 6 changes how it exports default on stack overflow.
// ES5
var timer = require('react-timer-hoc').default;
// ES2015+
import React from 'react';
import ReactDOM from 'react-dom';
import timer from 'react-timer-hoc';
function myComponent({ timer }) {
return <div>Started { timer.tick * timer.delay }ms ago.</div>
}
const Timer1 = timer(1000)(myComponent);
const Timer2 = timer(2000)(myComponent);
ReactDOM.render(
<div>
<Timer1 />
<Timer2 />
</div>,
document.getElementById('app')
);
FAQs
A React timer higher-order component
The npm package react-timer-hoc receives a total of 157 weekly downloads. As such, react-timer-hoc popularity was classified as not popular.
We found that react-timer-hoc demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.