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="https://facebook.github.io/react/js/jsfiddle-integration.js"></script>
JavaScript 1.7
var Hello = React.createClass({
getInitialState: function() {
return {
value: 'My Value',
nested: {
nestedValue: 'My Nested Value'
}
}
},
onChange(prop,e) {
this.setState({[prop]:e.currentTarget.value})
},
render: function() {
return (
<div>
Update on simple attribute works:
<input type="text"
value={this.state.value}
onChange={this.onChange.bind(this,'value')} />
{this.state.value}
<br />
Update on nested attributes does not work:
<input type="text"
value={this.state.nested.nestedValue}
onChange={this.onChange.bind(this,'nested.nestedValue')} />
{this.state.nested.nestedValue}
</div>
);
}
});
React.render(<Hello name="World" />, document.body);