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

问题描述 投票:0回答:3

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

我正在开发 Nextjs 应用程序,但使用 antd 库时出现此错误。我正在使用模态组件和工具提示组件,这会导致打开和关闭时重新渲染并多次吐出此错误。当我将鼠标悬停在工具提示上时,它也是如此。有人经历过这个吗?你是怎么解决的?感谢您的回答!

从 'antd' 导入 { Button, Modal, Tooltip };

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>
reactjs next.js modal-dialog tooltip antd
3个回答
2
投票

就我而言,当我使用 React DevTools Chrome 扩展时,我遇到了以下错误。删除扩展错误后已修复


1
投票

enter image description here

我在使用antd文件上传时也遇到同样的错误。
但它是由 Chrome 扩展之一引入的,而不是 antd。
刷新 Chrome 扩展程序将消除此错误。


0
投票

我最近使用react-context-devtool chrome扩展看到了这种情况

https://chrome.google.com/webstore/detail/react-context-devtool/oddhnidmicpefilikhgegedibnefkcf

删除它解决了问题

© www.soinside.com 2019 - 2024. All rights reserved.