Problem Statement
Ref for DOM div:
Explanation
Type refs as the exact element or null. This works well with strict mode and avoids unsafe any.
Code Solution
SolutionRead Only
import { useRef, useEffect } from 'react';
function Panel(){
const ref = useRef<HTMLDivElement | null>(null);
useEffect(() => { ref.current?.focus?.(); }, []);
return <div ref={ref} tabIndex={-1} />;
}