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 ReplaceStateTest = React.createClass({
getInitialState: function() {
return {value: "test", updated: false};
},
componentWillReceiveProps: function(props) {
this.replaceState(props);
},
render: function() {
return (
<div>
<p>
this.state = {JSON.stringify(this.state)}
</p>
<p>
text input correctly clears the value:<br/>
<input type="text" value={this.state.value} />
</p>
<p>
textarea still shows old value<br/>
<textarea value={this.state.value} />
</p>
</div>
);
}
});
var component = React.render(<ReplaceStateTest />, document.body);
component.replaceProps({updated: true});