React JS TypeError:无法在areHookInputsEqual读取未定义的属性'length'

时间:2020-10-20 12:36:10

标签: reactjs react-hooks server-side-rendering react-dom react-dom-server

使用“ 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()

我不确定可能出了什么问题,因此没有共享的代码。

0 个答案:

没有答案