Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
tiandahui opened this issue Sep 11, 2023 · 7 comments
Open

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

tiandahui opened this issue Sep 11, 2023 · 7 comments

Comments

@tiandahui
Copy link

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
Copy link

我也遇到了同样的问题
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
Copy link

SADYX commented Sep 21, 2023

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

@Donlei
Copy link

Donlei commented Oct 11, 2023

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

@tiandahui
Copy link
Author

我也遇到了同样的问题 在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
Copy link
Author

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

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

@Donlei
Copy link

Donlei commented Oct 11, 2023

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

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

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

@tiandahui
Copy link
Author

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

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

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

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants