Update refs example code to use onChange

Fixes #1408.

Test Plan: Copy each code snippet into jsbin; type in the text box successfully; click the button and see the input clear (and in the second example, get focused).
This commit is contained in:
Ben Alpert
2014-04-14 16:22:04 -07:00
parent 6f3bde9c85
commit 004db11878

View File

@@ -15,7 +15,7 @@ Consider the case when you wish to tell an `<input />` element (that exists with
getInitialState: function() {
return {userInput: ''};
},
handleKeyUp: function(e) {
handleChange: function(e) {
this.setState({userInput: e.target.value});
},
clearAndFocusInput: function() {
@@ -30,7 +30,7 @@ Consider the case when you wish to tell an `<input />` element (that exists with
</div>
<input
value={this.state.userInput}
onKeyUp={this.handleKeyUp}
onChange={this.handleChange}
/>
</div>
);
@@ -91,7 +91,7 @@ It's as simple as:
getInitialState: function() {
return {userInput: ''};
},
handleKeyUp: function(e) {
handleChange: function(e) {
this.setState({userInput: e.target.value});
},
clearAndFocusInput: function() {
@@ -107,7 +107,7 @@ It's as simple as:
<input
ref="theInput"
value={this.state.userInput}
onKeyUp={this.handleKeyUp}
onChange={this.handleChange}
/>
</div>
);