ant-design / ant-design-icons

⭐ Ant Design SVG Icons
https://ant.design/components/icon/
MIT License
940 stars 577 forks source link

使用pnpm下在依赖,编译报错 #598

Open tiandahui opened 9 months ago

tiandahui commented 9 months ago

react版本: 18.2.21 antd版本: 5.8.4 antd-icon版本:5.2.6 使用import { AimOutlined } from '@ant-design/icons'; 编译报错: Warning: Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:

  1. You might have mismatching versions of React and the renderer (such as React DOM)
  2. You might be breaking the Rules of Hooks
  3. You might have more than one copy of React in the same app See https://reactjs.org/link/invalid-hook-call for tips about how to debug and fix this problem.

Uncaught TypeError: Cannot read properties of null (reading 'useContext') at Object.useContext (react.development.js:1616:1) at AntdIcon.js:31:1

sunyongming commented 9 months ago

我也遇到了同样的问题 在Umi Max 项目下

"dependencies": { "@ant-design/icons": "^5.2.6", "@ant-design/pro-components": "^2.6.18", "@umijs/max": "^4.0.80", "antd": "^5.9.0", },

SADYX commented 9 months ago

"@ant-design/icons": "^5.2.6", "umi": "^4.0.81",

Donlei commented 8 months ago

image 同样遇到 这个问题 ,把button icon 注释掉就不会报错了。 错误提示说是,没有把 hook 当做一个 Function Component ,而是当做了 Function 进行调用。

tiandahui commented 8 months ago

我也遇到了同样的问题 在Umi Max 项目下

"dependencies": { "@ant-design/icons": "^5.2.6", "@ant-design/pro-components": "^2.6.18", "@umijs/max": "^4.0.80", "antd": "^5.9.0", },

我把react版本降为18.1.0就可以使用,不知道是不是icon为兼容新版本react

tiandahui commented 8 months ago

image 同样遇到 这个问题 ,把button icon 注释掉就不会报错了。 错误提示说是,没有把 hook 当做一个 Function Component ,而是当做了 Function 进行调用。

你看看你react的版本号 可以尝试下降版本号,暂时不知道有其他什么方法

Donlei commented 8 months ago

image 同样遇到 这个问题 ,把button icon 注释掉就不会报错了。 错误提示说是,没有把 hook 当做一个 Function Component ,而是当做了 Function 进行调用。

你看看你react的版本号 可以尝试下降版本号,暂时不知道有其他什么方法

我没有 降react版本 ,而是把icons的版本 降为5.2.5就好了

tiandahui commented 8 months ago

image 同样遇到 这个问题 ,把button icon 注释掉就不会报错了。 错误提示说是,没有把 hook 当做一个 Function Component ,而是当做了 Function 进行调用。

你看看你react的版本号 可以尝试下降版本号,暂时不知道有其他什么方法

我没有 降react版本 ,而是把icons的版本 降为5.2.5就好了

这样也可以,要不降icon的版本 要不就是降react版本,,应该就是react最新版本和 icon的最新版本不兼容的问题