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} />;
};
- Typescript Elements useRef React HTMLtypescript elements useref react useripple houdini useref react useref react usecontext useref react 组件 方法useref react useref react hooks components instances elements react typescript workspace monorepo react typescript component strongly react typescript component generics react