Created
June 6, 2018 21:44
-
-
Save gladchinda/08abb37b615bf8e5e3b2cb2d77b314a8 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
class FormInput extends React.Component { | |
constructor(props) { | |
super(props); | |
this.textInput = React.createRef(); | |
} | |
hasText() { | |
return this.textInput.current.value.length > 0; | |
} | |
selectInputText() { | |
this.textInput.current.select(); | |
} | |
render() { | |
return ( | |
<div> | |
{/* Creating a string ref named: textInput */} | |
<input type="text" ref={this.textInput} /> | |
</div> | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment