【发布时间】:2018-06-19 17:44:01
【问题描述】:
目前与我合作的客户要求我构建一个包含 i18n 的 SSR React 应用程序。为了解决这个问题,我尝试使用 NextJS 和 i18Next。
我设法让 react 和 apollo 毫无问题地连接起来,但是当我尝试连接 next + i18n 时,我不断收到一个非常无用的“意外错误”,错误。
检查控制台我还看到以下内容:
Cannot read property 'prototype' of undefined
TypeError: Cannot read property 'prototype' of undefined
at Object.inherits (http://localhost:3000/_next/1515592576452/page/index.js:36080:46)
at Object.<anonymous> (http://localhost:3000/_next/1515592576452/page/index.js:30216:6)
at Object.<anonymous> (http://localhost:3000/_next/1515592576452/page/index.js:30440:30)
at __webpack_require__ (http://localhost:3000/_next/1515592576452/manifest.js:714:31)
at fn (http://localhost:3000/_next/1515592576452/manifest.js:117:20)
at Object.<anonymous> (http://localhost:3000/_next/1515592576452/page/index.js:28246:12)
at Object.module.exports.exports.byteLength (http://localhost:3000/_next/1515592576452/page/index.js:28507:30)
at __webpack_require__ (http://localhost:3000/_next/1515592576452/manifest.js:714:31)
at fn (http://localhost:3000/_next/1515592576452/manifest.js:117:20)
at Object.<anonymous> (http://localhost:3000/_next/1515592576452/page/index.js:24501:18)
还有这个警告,但我不确定它是否相关
warning.js?e7f4ca8:33 Warning: Expected server HTML to contain a matching <div> in <div>.
我还注意到在 ./libs/withData.js 中有以下行:
enter code herestatic displayName = WithData(${getComponentDisplayName(
ComposedComponent
)})
我的编辑器将其标记为无效令牌,但此代码来自 nextjs example,并且该 repo 上没有问题,这表明这是一个错字。
我已在以下 codepen 项目中包含与此问题相关的所有代码。
【问题讨论】:
标签: javascript next.js apollo react-i18next