Browse Source

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).
main
Ben Alpert 11 years ago
parent
commit
004db11878
  1. 8
      docs/07.1-more-about-refs.md

8
docs/07.1-more-about-refs.md

@ -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>
);

Loading…
Cancel
Save