reactjs - TypeError:无法读取未定义的属性“间距”
问题描述
使用 React 和 Material UI 时出现以下错误
TypeError:无法读取未定义的属性“间距”
这是代码:
buttonTeal: {
margin: theme.spacing(1),
color:'white',
backgroundColor: '#009688',
它被渲染
const classes = useStyles();
解决方案
我明白了,我将样式移到了钩子中并更改了
export default withStyles(useStyles)(Hookname);
至
export default Hookname;
并添加
const useStyles = makeStyles(theme => ({
而不是
const useStyles = theme => ({
推荐阅读
- python - 在python中读取.bin文件
- python - Python中具有多个X特征和单个Y的散点图
- java - 如何在不知道哪个端点更大的情况下制作通用 for 循环?
- r - 删除异常值并适当减少 ggplot2 中每个方面的 yLim
- graphql - 如何在不迭代的情况下访问数组中的特定元素?
- kubernetes - 我们如何在 Azure AKS 集群中查找 service-cluster-ip-range
- azure - ARM 模板 Azure Web App - 如何指定堆栈设置(.NET、.NET Core、...)?
- spring-mvc - 不支持的媒体类型 415 @RequestBody 不工作但 @RequestParam 工作
- mysql - MySQL:返回按日期分组的统计信息和子查询
- port - 在 GoJS 中,如何防止端口的创建传播到所有对象?