Skip to content

Commit

Permalink
More explicit class method for ref doc (#10228)
Browse files Browse the repository at this point in the history
After realizing this was the second time I've visited this exact page within a year and second guessing myself that the `textInput` ref isn't actually the `<input />` element. I decided to attempt to make this a little more explicit; you are actually accessing the method on the child class and not the `focus` method on the dom input element. Having them named the same caused some confusion.
  • Loading branch information
hartzis authored and sophiebits committed Sep 10, 2017
1 parent 0440157 commit 6d37c05
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions docs/docs/refs-and-the-dom.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ When the `ref` attribute is used on an HTML element, the `ref` callback receives
class CustomTextInput extends React.Component {
constructor(props) {
super(props);
this.focus = this.focus.bind(this);
this.focusTextInput = this.focusTextInput.bind(this);
}
focus() {
focusTextInput() {
// Explicitly focus the text input using the raw DOM API
this.textInput.focus();
}
Expand Down Expand Up @@ -77,7 +77,7 @@ When the `ref` attribute is used on a custom component declared as a class, the
```javascript{3,9}
class AutoFocusTextInput extends React.Component {
componentDidMount() {
this.textInput.focus();
this.textInput.focusTextInput();
}
render() {
Expand Down

0 comments on commit 6d37c05

Please sign in to comment.