<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

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

  1. https://unpkg.com/react@17/umd/react.development.js
  2. https://unpkg.com/react-dom@17/umd/react-dom.development.js