[react] Property ‘addEventListener‘ does not exist on type ‘never‘

news/2024/7/15 17:13:32 标签: react.js

problem

react hook模式,使用useRef,设置click事件监听

const parentRef = useRef(null);
useEffect(()=>{
   
    parentRef.current?.addEventListener('click',(<

http://www.niftyadmin.cn/n/1463069.html

相关文章

[react] Target container is not a DOM element

error 控制台报错&#xff1a;Target container is not a DOM element reason js没找到dom节点&#xff0c; 原因是script引入的js代码在head里&#xff0c;先执行script脚本内容&#xff0c; 然后渲染dom节点&#xff0c;而js脚本需要用到dom节点&#xff0c;发现没找到&am…

[react] This synthetic event is reused for performance reasons. If you‘re seeing this, you‘re access

error This synthetic event is reused for performance reasons. If you’re seeing this, you’re accessing the property target on a released/nullified synthetic event. This is set to null. If you must solution e.persist()

[react] Type ‘string‘ is not assignable to type ‘FlexDirection | undefined‘. TS2322

problem 通过style inline方式style object设定样式 <div style{parentStyle} ref{parentRef}>{/*...*/} </div>const parentStyle {width: 60vw,height: 20vw,color: #fff,backgroundColor: darkred,display: flex,alignItems: center,flexDirection: column,ju…

@data注解语法无法识别

problem data注解语法无法识别 solution intelli 编译器安装插件 lombok 配置路径&#xff1a;IntelliJ IDEA -> preferences->Plugins

[react]Duplicate identifier ‘LibraryManagedAttributes‘.

problem 获取开源react项目&#xff0c;一顿操作&#xff1a; npm install, npm run start 页面报错&#xff1a; types/react/index.d.ts Duplicate identifier ‘LibraryManagedAttributes’. reason 应该是依赖原因 solution 改为yarn安装 rm -rf node_modules yarn…

[ts] .vite/vue.js oes not provide an export named ‘PropType‘

enviroment vite vue3 set-up mode error import {defineProps, PropType, ref, computed} from "vue"; defineProps({titleInfo: {type: Object as PropType<TitleInfo

[typescript] 无法重新声明块范围变量“user”。test_function.ts(75, 5): ‘user‘ was also declared here.

error 定义重复 函数实现重复 无法重新声明块范围变量“user”。test9_function.ts(75, 5): ‘user’ was also declared here. reason 原因是同一个文件夹下&#xff0c;其它文件里有同样的变量定义 resolution 在 Typescript 中&#xff0c;只要文件存在 import 或 expo…

[typescript] ERROR TS18003: No inputs were found in config file ‘tsconfig.json‘. Specified ‘include‘

reason src目录下没有.ts文件 resolution 在src目录下新增一个空的test.ts文件即可