<commit_before># react-interval

[![Version](http://img.shields.io/npm/v/react-interval.svg)](https://www.npmjs.org/package/react-interval)

A [react](https://github.com/facebook/react) setInterval 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 Interval = require("react-interval")

module.exports = React.createClass({
	mixins: [Interval()],

	componentDidMount: function () {
		var self = this

		this.setInterval(function () {
			self.setState({ lastUpdated: new Date() })
		}, 1000)

		this.setIntervalAsync(function () {
			request.get("myapi.com/data", function(err, res) {
				// component may have unmounted before request finished
				if (!self.isMounted) return

				self.setState({ data: res.body })
			})
		}, 4000)
	},

	render: function () {
		// ... etc
	}
})
```

<commit_msg>README: fix example for setIntervalAsync<commit_after># react-interval

[![Version](http://img.shields.io/npm/v/react-interval.svg)](https://www.npmjs.org/package/react-interval)

A [react](https://github.com/facebook/react) setInterval 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 Interval = require("react-interval")

module.exports = React.createClass({
	mixins: [Interval()],

	componentDidMount: function () {
		var self = this

		this.setInterval(function () {
			self.setState({ lastUpdated: new Date() })
		}, 1000)

		this.setIntervalAsync(function (callback) {
			request.get("myapi.com/data", function(err, res) {
				// component may have unmounted before request finished
				if (!self.isMounted) return callback()

				self.setState({ data: res.body })

				callback()
			})
		}, 4000)
	},

	render: function () {
		// ... etc
	}
})
```


{'fraction_non_alphanumeric': 0.14376218323586745, 'fraction_numerical': 0.007797270955165692, 'mean_word_length': 3.911483253588517, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 4, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1581166', 'n_tokens_mistral': 699, 'n_tokens_neox': 607, 'n_words': 171}