You may not use the ref attribute on function components
classCustomTextInputextendsReact.Component {constructor(props) {super(props);// create a ref to store the textInput DOM elementthis.textInput =React.createRef();this.focusTextInput =this.focusTextInput.bind(this); }focusTextInput() {// Explicitly focus using the raw DOM APIthis.textInput.current.focus(); }render() {// associate <input> ref with `textInput`return ( <div> <inputtype="text"ref={this.textInput} /> <inputtype="button"value="Focus the text input"onClick={this.focusTextInput} /> </div> ); }}