[React Typescript] useRef with HTML Elements
React set the ref to null
in runtime. It is a limitation now for react.
import { useRef } from 'react';
export const Component = () => {
const ref = useRef<HTMLDivElement>(null);
return <div ref={ref} />;
};