import { forwardRef } from 'react';
const MyInput = forwardRef((props, ref) => {
const { label, ...otherProps } = props;
<input {...otherProps} ref={ref} />
const inputRef = useRef(null);
function handleFocus() {
inputRef.current.focus();
<MyInput ref={inputRef} label="Enter your name" />
<button onClick={handleFocus}>Focus the input</button>