From e1689b0f20fbf3ece7e27597702f5794a446eb67 Mon Sep 17 00:00:00 2001 From: Sean Snyder Date: Thu, 5 Apr 2018 14:16:00 -0400 Subject: [PATCH] Move constructor out of render --- content/docs/accessibility.md | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/content/docs/accessibility.md b/content/docs/accessibility.md index 6ba47f6a..4d824a45 100644 --- a/content/docs/accessibility.md +++ b/content/docs/accessibility.md @@ -147,21 +147,22 @@ To set focus in React, we can use [Refs to DOM elements](/docs/refs-and-the-dom. Using this, we first create a ref to an element in the JSX of a component class: ```javascript{4-5,8-9,13} -render() { +class CustomTextInput extends React.Component { constructor(props) { super(props); // Create a ref to store the textInput DOM element this.textInput = React.createRef(); } - // ... + render() { // Use the `ref` callback to store a reference to the text input DOM // element in an instance field (for example, this.textInput). - return ( - - ); + return ( + + ); + } } ```