NextJS/Typescript/Apollo 错误;类型上不存在属性

Mat*_*att 2 typescript apollo reactjs strapi next.js

我对 NextJS 和 Typescript 相当陌生,并且我\xe2\x80\x99m 实现了无头 CMS Strapi,但在使用 Apollo 时遇到了问题。我整个周末都在谷歌上搜索xe2x80x99,试图更好地理解这个问题。我希望有人能在这里帮助我。

\n\n

错误

\n\n

在我的中收到以下错误_app.tsx

\n\n
Property \'apollo\' does not exist on type \'AppPropsType<Router, {}>\'.\n
Run Code Online (Sandbox Code Playgroud)\n\n

我的下面的函数发生了错误MyApp

\n\n

我的_app.tsx

\n\n
import * as React from \'react\'\nimport { AppProps } from \'next/app\'\nimport { ApolloProvider } from \'@apollo/react-hooks\'\nimport withData from \'../../utils/apollo\'\n\nimport \'circular-std\'\nimport \'react-multi-carousel/lib/styles.css\'\nimport \'../scss/styles.scss\'\n\nfunction MyApp({ Component, pageProps, apollo }: AppProps) {\n  return (\n    <ApolloProvider client={apollo}>\n      <Component {...pageProps} />\n    </ApolloProvider>\n  )\n}\n\nexport default withData(MyApp)\n
Run Code Online (Sandbox Code Playgroud)\n\n

相应的Strapi 设置教程位于前端设置第 3 部分。

\n

The*_*eoG 5

或者,我已经执行了以下操作:

import App, { AppProps  } from 'next/app';
import { ApolloProvider, ApolloClient } from '@apollo/client';

interface Props {
  apollo: ApolloClient<{}>;
}

const MyApp = ({ Component, pageProps, apollo }: AppProps & Props) => {
}
Run Code Online (Sandbox Code Playgroud)