import { useRef, JSX } from "react"; export default function InputFocus(): JSX.Element { // 1. Create a ref (initially null) const inputRef = useRef(null); const handleClick = () => { // 3. Access the native DOM element via .current and focus it inputRef.current?.focus(); }; return (
{/* 2. Attach the ref to the JSX element */}
); }