【发布时间】:2019-06-04 17:35:43
【问题描述】:
从 v3.9.x 升级到 MUI v4.0.2 后出现以下错误:
您必须将组件传递给 connect 返回的函数。而是收到 {"propTypes":{},"displayName":"WithStyles(MyComponent)","options":{"defaultTheme":{"breakpoints":{"keys":["xs","sm"," md","lg","xl"],"值": ...
我的组件:
import { withStyles } from '@material-ui/core/styles'
const getStyles = theme => ({
fooBar: {
...
},
})
...
export default withStyles(getStyles)(MyComponent)
我的容器:
import { connect } from 'react-redux'
import MyComponent from './MyComponent'
...
export default connect(mapStateToProps, mapDispatchToProps)(MyComponent)
如何迁移withStyles?
【问题讨论】:
-
你使用的是什么版本的 react-redux?我认为这与github.com/reduxjs/react-redux/issues/914 有关,如果您使用的是 react-redux 6 或 7 版,我认为应该修复。
-
@RyanCogswell 这已经解决了这个问题!将
react-redux从 5.x 升级到 7.0 后,问题就消失了!请写一个答案,以便我可以接受它,未来的人会立即知道解决方案。 ??????
标签: reactjs migration material-ui