JZTXT
  • 首页
  • Ai
  • Java
  • Python
  • Android
  • Mysql
  • JavaScript
  • Html
  • CSS

[React Typescript] useRef with HTML Elements

发布时间 2023-05-24 15:17:57作者: Zhentiw

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} />;
};

 

    本栏目推荐文章
  • 跟着阿灵学前端(1)——HTML 基础
  • 2024-01-13 记录react-dnd拖拽组件的用法
  • 2024-01-13 react 监听上一页返回
  • 一行代码创建网页(html)
  • HTML
  • [JMeter] JMeter的测试报告格式转换(.jtl => html)
  • js string转html节点
  • 2024-01-13 Can't perform a React state update on an unmounted component. This is a no-op, but it indicates a memory leak in your application. ==》引用了未使用的方法导致
  • PHPExcel读取excel文件并保存成html文件
  • 002*:React状态、属性、传值
版权声明:本网站为非赢利性站点,本网站所有内容均来源于互联网相关站点自动搜索采集信息,相关链接已经注明来源。
联系我们