react-interval-update
v0.2.0
Published
Re-render a component at every interval
Downloads
4
Readme
React Interval Update
Installation
npm i --save react-interval-update
Usage
As a HOC
import { withInterval } from 'react-interval-update';
const CurrentTimeWithUpdater = ({ onIntervalChange, interval }) => (
<div>
{new Date().toString()}
<br />
Update interval:
<input
value={interval}
onChange={({ target }) => onIntervalChange(parseInt(target.value, 10))}
/>
</div>
);
export default withInterval(CurrentTimeWithUpdater, { interval: 5000, prop: 'update' });
As a component
import { Interval } from 'react-interval-update';
const CurrentTime = () => new Date().toString();
return (
<Interval interval={1000}>
<CurrentTime />
</Interval>
);