Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dcousens/react-timers
A react setInterval/setTimeout mixin for mere mortals
https://github.com/dcousens/react-timers
Last synced: 4 months ago
JSON representation
A react setInterval/setTimeout mixin for mere mortals
- Host: GitHub
- URL: https://github.com/dcousens/react-timers
- Owner: dcousens
- License: mit
- Archived: true
- Created: 2015-04-30T01:15:19.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2018-10-01T02:01:40.000Z (about 6 years ago)
- Last Synced: 2024-06-22T20:22:09.053Z (6 months ago)
- Language: JavaScript
- Homepage:
- Size: 28.3 KB
- Stars: 29
- Watchers: 4
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# DEPRECATED: use [react-timer-mixin](https://github.com/reactjs/react-timer-mixin) instead
### react-timers[![Version](http://img.shields.io/npm/v/react-timers.svg)](https://www.npmjs.org/package/react-timers)
A [react](https://github.com/facebook/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
``` javascript
var Timers = require('react-timers')module.exports = React.createClass({
mixins: [Timers],componentDidMount: function () {
var self = thisthis.setTimeout(function () {
self.setState({ lastUpdated: new Date() })
}, 1000)this.setInterval(function () {
self.setState({ lastUpdated: new Date() })
}, 1000)
},render: function () {
// ... etc
}
})
```## LICENSE [MIT](LICENSE)