I have a React component similar to this:
var Example = React.createClass({
render: function() {
return <input type="text"
onChange = {this.onChange}
value = {this.text}
data-what = {this.text} />;
}
});
I have a unit test in which I do this:
- Use
TestUtils.renderIntoDocumentto create the component, using "FIRST" as thestate.text. - Use
Simulate.changeto change the text to "SECOND".
How here's the weirdest thing. If I dump the HTML after each step, I expect to see:
<input type="text" data-what="FIRST" value="FIRST">
<input type="text" data-what="SECOND" value="SECOND">
…but for some bizarre reason, I keep getting these results:
<input type="text" data-what="FIRST" value="FIRST">
<input type="text" data-what="SECOND" value="FIRST">
In the second dump, value is still "FIRST". What??
Clearly the plumbing is working because data-what is correctly changed to "SECOND" but why isn't the value?? Very confused.
Aucun commentaire:
Enregistrer un commentaire