【发布时间】:2019-03-10 10:41:36
【问题描述】:
我想写a functional stateless component in ReactJs as described here的样式。
const MyBlueButton = props => {
const styles = { background: 'blue', color: 'white' };
return <button {...props} style={styles} />;
};
问题是我想添加一些styles from stateful components as described here。
const styles = theme => ({
root: {
width: '100%',
maxWidth: 360,
backgroundColor: theme.palette.background.paper,
},
});
问题是当我尝试做这样的事情时:
<div className={classes.root}>
我得到错误:
'classes' 未定义 no-undef
如何访问 withStyles classes 对象以按照我想要的方式设置 root?
【问题讨论】:
-
你想在这里使用
react-jss库吗? -
哦,对不起。
material-ui在标签中,所以问题不是react-jss。但是,我还是不太明白这个问题 :) 你想将material-ui与功能组件一起使用吗?我不太了解material-ui,但尝试过并从道具中获取classes?
标签: css reactjs material-ui jsx