As long as both of your form inputs are: (1) managed inputs and (2) have a property valuethat points to the same data, any change to this data will update both inputs.
var SyncEdit = React.createClass({
getInitialState: function() {
return { text: "" };
},
render: function() {
return (
<div>
<input type="text" value={this.state.text} onChange={this.handleChange} />
<input type="text" value={this.state.text} onChange={this.handleChange} />
</div>
);
},
handleChange: function(evt) {
this.setState({text: evt.target.value});
}
});
React.renderComponent(<SyncEdit />, document.body);
Here's the JSFiddle for a demo : http://jsfiddle.net/BinaryMuse/2K5qX/
source
share