升级样式化组件v4时发生不变违规错误

时间:2019-02-12 05:48:28

标签: reactjs react-redux styled-components next.js

在将Next-react-redux应用程序上的现有样式化组件升级到v4时,我们遇到此错误:

  

不变违反:您必须将组件传递给connect返回的函数。而是收到{“ attrs”:[],“ componentStyle”:{“ rules”:[“。app&{”,null,“;”,null,“;}”],“ isStatic”:false,“ componentId” :“ withStyles-l4k83c-0”}

在我的package.json中:

"babel-cli": "^6.26.0",
"babel-preset-flow": "^6.23.0",
    "next": "^5.1.0",
    "next-redux-saga": "^1.0.1",
    "next-redux-wrapper": "^1.3.5",
    "next-routes": "^1.2.0",
"react": "^16.3.0",
"react-dom": "^16.3.0",
    "redux": "^3.7.2",
    "redux-devtools-extension": "^2.13.2",
    "redux-immutable": "^4.0.0",
    "redux-logger": "^3.0.6",
    "redux-saga": "^0.16.0",
"styled-components":  "^4.1.3", 

升级期间我缺少什么?

1 个答案:

答案 0 :(得分:0)

样式化组件开始从版本4开始使用React.forwardRef,而较早版本的react-redux确实对React组件进行了错误检查。因此react-redux应该至少更新到5.1.0-线程-> https://github.com/reduxjs/react-redux/issues/914