0

我正在使用 React 18 Release Candidate 开发一个新项目。一切正常,直到我安装了一个似乎正在使用它自己的 react 版本的包。我现在收到以下错误。

Error: 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

我很确定问题是(3),因为当我列出安装的反应版本时,我得到以下信息。

+-- @solana/wallet-adapter-react@0.15.3
| `-- react@17.0.2
+-- @solana/wallet-adapter-react-ui@0.9.5
| `-- react@17.0.2
`-- UNMET PEER DEPENDENCY react@18.0.0-rc.0

那么,我认为这里的问题是 Solana 钱包想要 React 17 并且对 React 18 不满意,我是否正确?这可能是导致钩子错误的原因吗?

如果是这样,有没有办法在不将 React 降级到 v17 的情况下修复它?

4

0 回答 0