[英]How do I wrap react redux connect inside Radium?
Typically when I use Radium in my React app, I would simply wrap my exported class inside Radium 通常,当我在React应用程序中使用Radium时,我只需将导出的类包装在Radium中
export default Radium(App)
and media queries would work as expected. 并且媒体查询将按预期工作。 However, I want to use both connect from react-router
alongside Radium like this: 但是,我想像下面这样同时使用来自react-router
和Radium的连接:
//Imports
import React from 'react'
import Radium from 'radium'
import { Table, TableBody } from 'material-ui/Table'
import { connect } from 'react-redux
const tableWrapper = {
width: '100%',
'@media screen and (max-width: 799px)': {
width: '50%'
}
}
render() {
<Table wrapperStyle={tableWrapper}>
<TableBody>
...
</TableBody>
</Table>
}
function mapDispatchToProps(dispatch) {
return bindActionCreators(Object.assign({}, {update}), dispatch)
}
export default connect(null, mapDispatchToProps)(Radium(App))
export { App as AppNoRadium }
but I continue to receive the warning/error when I apply my styles: 但应用样式时,我仍然收到警告/错误:
Warning: Unsupported style property @media screen and (max-width: 799px). 警告:不支持的样式属性@media屏幕和(最大宽度:799px)。 Did you mean @media screen and (maxWidth: 799px)? 您是说@media屏幕和(最大宽度:799px)吗?
Am I incorrectly wrapping my component inside Radium? 我是否在Radium中错误地包装了组件?
Why are you exporting file again in the end . 为什么最后又要导出文件。 Use following 使用以下
Login = connect(mapStateToProps, { })(Radium(Login));
export default Login;
This will work fine. 这样就可以了。 Don't forget to import radium on top :) 不要忘记在顶部进口镭:)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.