集成Material UI挂钩和Apollo挂钩的错误

时间:2019-01-12 00:53:56

标签: material-ui apollo next.js react-hooks

当将材料UI挂钩(如其example shown here)与NextJS和react-apollo-hooks一起使用时,会收到错误-

TypeError: Cannot read property 'theme' of undefined
    at MyDocument.render (/material-ui/examples/nextjs-hooks-with-typescript/.next/server/static/development/pages/_document.js:156:38)

预期的行为

能够同时使用Material UI挂钩和Apollo挂钩。

当前行为

undefined pageContext导致TypeError: Cannot read property 'theme' of undefined在以下行: https://github.com/ivawzh/material-ui/blob/fc6ae01e66bde4252a08903719a59ef108e05e5f/examples/nextjs-hooks-with-typescript/pages/_document.tsx#L14

image

复制步骤

This codesandbox.io template _may_ be a good starting point: https://codesandbox.io/s/github/mui-org/material-ui/tree/master/examples/create-react-app If you're using typescript a better starting point would be https://codesandbox.io/s/github/mui-org/material-ui/tree/master/examples/create-react-app-with-typescript If YOU DO NOT take time to provide a codesandbox.io reproduction, should the COMMUNITY take time to help you? ->

我在这里https://github.com/ivawzh/material-ui/commit/fc6ae01e66bde4252a08903719a59ef108e05e5f

准备了一个回购协议

步骤:

  1. git clone git@github.com:ivawzh/material-ui.git
  2. cd material-ui/examples/nextjs-hooks-with-typescript
  3. npm install && npm run dev
  4. 在网络浏览器中,打开http://localhost:3000/countries2
  5. 在终端中查看错误

上下文

我正在尝试将Apollo挂钩与Material UI挂钩示例结合使用。 从上面的存储库中,您将看到http://localhost:3000/countries处的非挂钩Apollo端点按预期工作正常。但是,当使用Apollo挂钩时,由于pageContext变得不确定,应用将崩溃。

环境

https://github.com/ivawzh/material-ui/tree/fc6ae01e66bde4252a08903719a59ef108e05e5f/examples/nextjs-hooks-with-typescript

|技术|版本| | -------------- || --------- | | Material-UI | v3.8.1 | |反应| 16.7.0-alpha.2 | |浏览器镀铬| |打字稿| 3.2.2 | |反应阿波罗| 2.3.3 | |反应阿波罗钩| 0.2.1 |

相关的Git问题

0 个答案:

没有答案