如何解决@apollo modules 导致 React 项目中的问题?

How to solve @apollo modules causes problems In react project?

Ex - 我安装了 @apollo/react-components 以在 React 项目中使用 ApolloProvider,它导致了以下错误:

./node_modules/@apollo/react-hooks/lib/react-hooks.esm.js Module not found: Can't resolve 'apollo-client'

因为 withApollo 现在是@apollo/client 的一部分。将导入更改为此应该可以解决错误。

import { withApollo } from '@apollo/client/react/hoc'