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

Loading…
Cancel
Save