-
-
Save yushanwebdev/2ca30f8911996009d917bd4fe3be2c05 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { Component, createRef } from "react"; | |
class CustomTextInput extends Component { | |
textInput = createRef(); | |
focusTextInput = () => this.textInput.current.focus(); | |
render() { | |
return ( | |
<> | |
<input type="text" ref={this.textInput} /> | |
<button onClick={this.focusTextInput}>Focus the text input</button> | |
</> | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment