使用“ react-dom / server”
中的 renderToString 在SSR呈现某些URL时,我遇到一些错误。我遇到以下错误:
TypeError: Cannot read property 'length' of undefined
at areHookInputsEqual (C:\projects\spd-web-app1\node_modules\react-dom\cjs\react-dom-server.node.development.js:992:38)
at Object.useMemo (C:\projects\spd-web-app1\node_modules\react-dom\cjs\react-dom-server.node.development.js:1230:13)
at useMemo (C:\projects\spd-web-app1\node_modules\react\cjs\react.development.js:1521:21)
at Provider (C:\projects\spd-web-app1\node_modules\react-redux\lib\components\Provider.js:22:41)
at finishHooks (C:\projects\spd-web-app1\node_modules\react-dom\cjs\react-dom-server.node.development.js:1077:16)
at processChild (C:\projects\spd-web-app1\node_modules\react-dom\cjs\react-dom-server.node.development.js:3046:14)
at resolve (C:\projects\spd-web-app1\node_modules\react-dom\cjs\react-dom-server.node.development.js:2962:5)
at ReactDOMServerRenderer.render (C:\projects\spd-web-app1\node_modules\react-dom\cjs\react-dom-server.node.development.js:3437:22)
at ReactDOMServerRenderer.read (C:\projects\spd-web-app1\node_modules\react-dom\cjs\react-dom-server.node.development.js:3375:29)
at renderToString (C:\projects\spd-web-app1\node_modules\react-dom\cjs\react-dom-server.node.development.js:3990:27)
我发现的是在 react-dom-server.node.development.js 中→ createWorkInProgressHook()
我正在下面的对象中,其中 memoizedState 不是数组。
{
memoizedState: 0,
queue: { last: null, dispatch: [Function: bound dispatchAction] },
next: {
memoizedState: { current: [QueryData] },
queue: null,
next: { memoizedState: [Object], queue: null, next: [Object] }
}
}
在 useMemo()中使用的
var prevDeps = prevState[1];
将返回未定义,从而导致 areHookInputsEqual()
我不确定可能出了什么问题,因此没有共享的代码。