0

目前与我合作的客户要求我构建一个包含 i18n 的 SSR React 应用程序。为了解决这个问题,我尝试使用 NextJS 和 i18Next。

我设法让反应和阿波罗毫无问题地连接起来,但是当我尝试连接下一个 + 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 here静态显示名称 =WithData(${getComponentDisplayName( ComposedComponent )})

我的编辑器将其标记为无效令牌,但此代码来自nextjs 示例,并且该 repo 上没有问题,这表明这是一个错字。

我已在以下 codepen 项目中包含与此问题相关的所有代码。

https://codepen.io/foxleigh81/project/editor/DnYJWB

4

1 回答 1

0

好的,我已经解决了。

简而言之。我在想这一切都错了。我在想我是在我的 react 应用程序旁边添加的,而现实更像是我将我的 react 应用程序放在里面。我把它拆开并从头开始重建,在nextjs repo 上组装示例,一切正常。

于 2018-01-10T16:23:39.710 回答