Skip to content

Instantly share code, notes, and snippets.

@cecigarcia
Created June 27, 2019 09:12
Show Gist options
  • Save cecigarcia/fe9ce43a1c225dd6c529358bd1fedbaf to your computer and use it in GitHub Desktop.
Save cecigarcia/fe9ce43a1c225dd6c529358bd1fedbaf to your computer and use it in GitHub Desktop.
import React, { useRef } from "react";
const CustomTextInput = () => {
const textInput = useRef();
focusTextInput = () => textInput.current.focus();
return (
<>
<input type="text" ref={textInput} />
<button onClick={focusTextInput}>Focus the text input</button>
</>
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment