From 2f97f485cef7662177b5ec0a81df1da6ecad4592 Mon Sep 17 00:00:00 2001 From: Brian Vaughn Date: Wed, 14 Mar 2018 18:01:20 -0700 Subject: [PATCH] Fixed docs --- content/docs/refs-and-the-dom.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/content/docs/refs-and-the-dom.md b/content/docs/refs-and-the-dom.md index 55edec89..845529b9 100644 --- a/content/docs/refs-and-the-dom.md +++ b/content/docs/refs-and-the-dom.md @@ -279,18 +279,18 @@ class CustomTextInput extends React.Component { this.textInput = null; this.setTextInputRef = element => { - this.textInput = element + this.textInput = element; }; this.focusTextInput = () => { // Focus the text input using the raw DOM API - this.textInput.focus(); + if (this.textInput) this.textInput.focus(); }; } - componentDidMount () { + componentDidMount() { // autofocus the input on mount - if (this.textInput.current) this.focusTextInput() + this.focusTextInput(); } render() {