https://github.com/dcousens/react-timers
A react setInterval/setTimeout mixin for mere mortals
https://github.com/dcousens/react-timers
Last synced: 2 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 10 years ago)
- Default Branch: master
- Last Pushed: 2018-10-01T02:01:40.000Z (about 7 years ago)
- Last Synced: 2025-08-09T14:50:53.833Z (3 months ago)
- Language: JavaScript
- Homepage:
- Size: 28.3 KB
- Stars: 29
- Watchers: 3
- 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
[](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 = 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)