3

我在使用“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.jscreateWorkInProgressHook()

我得到下面的对象,其中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];中使用时 将返回 undefined 并因此导致areHookInputsEqual() 出现问题

我不确定可能出了什么问题,所以没有代码可以分享。

4

0 回答 0