JSFiddle - React, Tailwind, and code Playground
HTML
<script src="http://fb.me/react-with-addons-0.11.0.js"></script>
<script src="http://fb.me/JSXTransformer-0.11.0.js"></script>
<script src="http://fb.me/react-js-fiddle-integration.js"></script>
JavaScript 1.7
/** @jsx React.DOM */
var update = React.addons.update;
var MultipleSetState = React.createClass({
getInitialState () {
return {
text: '',
click: false
}
},
handleBlur (e) {
this.setState(
update(this.state, {text : {$set: e.target.value}})
);
},
handleClick () {
this.setState(
update(this.state, {click: {$set: true}})
);
},
render () {
console.log(this.state);
return (
<div>
<input type="text" onBlur={this.handleBlur} autofocus />
<button onClick={this.handleClick}>button</button>
<pre>{JSON.stringify(this.state, undefined, 2)}</pre>
</div>
);
}
});
React.renderComponent(<MultipleSetState />, document.body);