当将材料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
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
准备了一个回购协议步骤:
git clone git@github.com:ivawzh/material-ui.git
cd material-ui/examples/nextjs-hooks-with-typescript
npm install && npm run dev
http://localhost:3000/countries2
我正在尝试将Apollo挂钩与Material UI挂钩示例结合使用。
从上面的存储库中,您将看到http://localhost:3000/countries
处的非挂钩Apollo端点按预期工作正常。但是,当使用Apollo挂钩时,由于pageContext
变得不确定,应用将崩溃。
|技术|版本| | -------------- || --------- | | Material-UI | v3.8.1 | |反应| 16.7.0-alpha.2 | |浏览器镀铬| |打字稿| 3.2.2 | |反应阿波罗| 2.3.3 | |反应阿波罗钩| 0.2.1 |