Skip to content

Instantly share code, notes, and snippets.

@rippo
Created July 1, 2015 10:19
Show Gist options
  • Save rippo/2ee0a2c9cc23534eb3a7 to your computer and use it in GitHub Desktop.
Save rippo/2ee0a2c9cc23534eb3a7 to your computer and use it in GitHub Desktop.
React linked state with mixin
var Hello = React.createClass({
mixins: [React.addons.LinkedStateMixin],
getInitialState: function() {
return {input: 0.2};
},
render: function() {
var total = this.state.input1 + this.state.input2;
return (
<div>{total}<br/>
<input type="text" valueLink={this.linkState('input')} />;
<input type="text" valueLink={this.linkState('input')} />;
</div>
);
}
});
React.render(<Hello />, document.getElementById('DemoApp'));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment