JSFiddle - React, Tailwind, and code Playground
HTML
<script src="http://fb.me/react-with-addons-0.12.0.js"></script>
<script src="http://fb.me/JSXTransformer-0.12.0.js"></script>
<script src="http://fb.me/react-js-fiddle-integration.js"></script>
JavaScript 1.7
var Container = React.createClass({
getInitialState: function() {
return {data: {key: "value"}};
},
shouldComponentUpdate: function(nextProps, nextState) {
return this.state.data.key != nextState.data.key;
},
render: function() {
return (
<div>
{this.state.data.key}
<button onClick={this.updateState}>Update</button>
</div>
);
},
updateState: function() {
// Modifying state is anti-pattern. We should clone it
this.state.data.key = "new value";
this.setState({data: this.state.data});
}
});
React.render(<Container />, document.body);