MENU
Accessing DOM Node
RESETRUNFULL
function TextInputWithFocusButton() {
const inputEl = React.useRef(null); // initialized to null
const onButtonClick = () => {
inputEl.current.focus();
};
return (<div><input ref={inputEl} type="text" />
<button onClick={onButtonClick}>Focus the input</button>
</div>);}ReactDOM.render(<TextInputWithFocusButton/>,document.querySelector("div"));