Skip to content

Instantly share code, notes, and snippets.

@gladchinda
Created June 6, 2018 21:48
Show Gist options
  • Save gladchinda/08406f74158a96b2995882c27ec84999 to your computer and use it in GitHub Desktop.
Save gladchinda/08406f74158a96b2995882c27ec84999 to your computer and use it in GitHub Desktop.
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