<div id="app"></app>
const { useRef } = React;
const Form = () => {
const inputRef = useRef();
const handleClick = () => {
inputRef.current.focus();
};
return (
<>
<input ref={inputRef}/>
<button onClick={handleClick}>Focus</button>
</>
);
};
ReactDOM.render(<Form />, document.getElementById('app'));
View Compiled
This Pen doesn't use any external CSS resources.