Skip to content

chevsky/react-timers

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

36 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

This library is free and open-source software released under the MIT license.

About

A react setInterval/setTimeout mixin for mere mortals

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 87.1%
  • HTML 12.9%