简体   繁体   English

类型错误:无法设置未定义的属性(设置“钩子”)

[英]TypeError: Cannot set properties of undefined (setting 'hook')

TypeError: Cannot set properties of undefined (setting 'hook')类型错误:无法设置未定义的属性(设置“钩子”)

I am working on a Nextjs application but getting this error with antd library.我正在开发 Nextjs 应用程序,但在使用 antd 库时出现此错误。 I'm using the modal component and tooltip component which causes a re-render on open and close and spits out this error multiple times.我正在使用模态组件和工具提示组件,这会导致在打开和关闭时重新渲染并多次吐出此错误。 Same goes for the tooltip when I mouse over it.当我将鼠标悬停在它上面时,工具提示也是如此。 Has anyone experienced this?有没有人经历过这个? and how did you fix it?.你是怎么解决的? Answers appreciated!回答赞赏!

import { Button, Modal, Tooltip } from 'antd'; import { Button, Modal, Tooltip } from 'antd';

const [isModalOpen, setIsModalOpen] = useState(false);

<div className="d-flex gap-2">
  <Tooltip title="Edit">
    <EditOutlined className="h5 pointer text-warning" />
  </Tooltip>
  <Tooltip title="Publish">
    <CheckOutlined className="h5 pointer text-success ml-2" />
  </Tooltip>
</div>

<Button
   className="w-100"
   onClick={() => setIsModalOpen(true)}
   type="primary"
   shape="round"
   size="large"
   icon={<UploadOutlined />}
>
 Open modal
</Button>

<Modal
   title="Modal title"
   centered
   open={isModalOpen}
   onCancel={() => setIsModalOpen(false)}
   footer={null}
>
  <p>Some contents...</p>
</Modal>

enter image description here在此处输入图像描述

I had the same error when using antd file upload.我在使用antd文件上传时出现了同样的错误。
But it was introduced by one of the Chrome extensions, not antd.但它是由 Chrome 扩展之一引入的,而不是 antd。
Refreshing the Chrome extension will remove this error.刷新 Chrome 扩展程序将消除此错误。

in my case I have got that below error, when I'm using React DevTools Chrome extension.在我的例子中,当我使用 React DevTools Chrome 扩展时,我遇到了以下错误。 after removing that extension error are fixed删除该扩展错误后已修复

在此处输入图像描述

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Next.js TypeError:无法设置未定义的属性(设置“挂钩”) - Next.js TypeError: Cannot set properties of undefined (setting 'hook') 类型错误:无法设置未定义的属性(设置“srcObject”) - TypeError: Cannot set properties of undefined (setting 'srcObject') TypeError:无法设置未定义的属性(设置“转换”) - TypeError: Cannot set properties of undefined (setting 'transform') 类型错误:无法设置未定义的属性(设置“授权”) - TypeError: Cannot set properties of undefined (setting 'Authorization') 类型错误:无法设置未定义的属性(设置“持续时间”) - TypeError: Cannot set properties of undefined (setting 'duration') 类型错误:无法在反应 js 中设置未定义的属性(设置“tabIndex”) - TypeError: Cannot set properties of undefined (setting 'tabIndex') in react js 未捕获的类型错误:无法设置未定义的属性(设置“全名”) - Uncaught TypeError: Cannot set properties of undefined (setting 'full_name') React 中的 Cleave.js:TypeError:无法设置未定义的属性(设置“元素”) - Cleave.js in React: TypeError: Cannot set properties of undefined (setting 'element') TypeError:无法设置未定义的属性(设置“样式”)+在 next.config.js NextJS 中使用 withLess/withSass/withCSS - TypeError: Cannot set properties of undefined (setting 'styles') + Using withLess/withSass/withCSS in next.config.js NextJS 无法设置未定义的属性(设置“播放器”)ReactPlayer - Cannot set properties of undefined (setting 'player') ReactPlayer
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM