This package has been deprecated

Author message:

use reactjs/react-timer-mixin instead

react-timers

5.0.3 • Public • Published

react-timers

Version

A react setInterval/setTimeout mixin for mere mortals. Any intervals that are set are automatically cleared based on the component life cycle.

WARNING: If you are performing an async action, you should still check if the component is mounted.

Example

var Timers = require('react-timers')
 
module.exports = React.createClass({
    mixins: [Timers],
 
    componentDidMount: function () {
        var self = this
 
        this.setTimeout(function () {
            self.setState({ lastUpdated: new Date() })
        }, 1000)
 
        this.setInterval(function () {
            self.setState({ lastUpdated: new Date() })
        }, 1000)
    },
 
    render: function () {
        // ... etc
    }
})

LICENSE [MIT][LICENSE]

Package Sidebar

Install

npm i react-timers

Weekly Downloads

10

Version

5.0.3

License

MIT

Last publish

Collaborators

  • dcousens
  • jedwatson