From 888a12b85d9b3c87a321499640250ef0147c4500 Mon Sep 17 00:00:00 2001 From: Brian Emil Hartz Date: Sun, 10 Sep 2017 15:48:39 -0600 Subject: [PATCH] More explicit class method for ref doc (#10228) 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 `` 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. --- docs/refs-and-the-dom.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/refs-and-the-dom.md b/docs/refs-and-the-dom.md index b6c91996..bb224bfe 100644 --- a/docs/refs-and-the-dom.md +++ b/docs/refs-and-the-dom.md @@ -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(); } @@ -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() {