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} />;
};
标签:react,useRef,Elements,Typescript,React,HTML From: https://www.cnblogs.com/Answer1215/p/17428382.html