Created
June 6, 2018 21:48
-
-
Save gladchinda/08406f74158a96b2995882c27ec84999 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
const MyComponent = (props) => { | |
const formInput = React.createRef(); | |
const inputSelection = () => { | |
const input = formInput.current; | |
if (input.hasText()) { | |
input.selectInputText(); | |
} | |
}; | |
return ( | |
<div> | |
<button type="button" onClick={inputSelection}> | |
Select Input | |
</button> | |
<FormInput ref={formInput} /> | |
</div> | |
); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment