【问题标题】:Invariant Violation error while upgrading styled-componentsv4升级 styled-componentsv4 时出现不变违规错误
【发布时间】:2019-07-05 17:10:35
【问题描述】:

在 Next-react-redux 应用程序上将现有的 styled-components 升级到 v4 时,我们收到此错误:

Invariant Violation:您必须将组件传递给 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", 

我在升级过程中遗漏了什么??

【问题讨论】:

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


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 2021-02-13
      • 1970-01-01
      • 2020-12-11
      • 2015-11-14
      • 2019-12-07
      • 2021-06-22
      • 2022-09-30
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多