react-timersdeprecated

A react setInterval/setTimeout mixin for mere mortals.

Usage no npm install needed!

<script type="module">
  import reactTimers from 'https://cdn.skypack.dev/react-timers';
</script>

README

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]