![](/img/trans.png)
[英]Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object in ReactJS
[英]Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object
我似乎遇到了这个以正确方式导出的模块的问题,但是当它被导入时,我得到了上面提到的错误。 有人可以帮忙吗? 任何东西都值得赞赏这是模块的代码
import React from "react";
import { makeStyles } from "@material-ui/core/styles";
import Typography from "material-ui/styles/typography";
const useStyles = makeStyles(theme => ({
maindiv: {
float: 'left',
},
}));
export default function Home() {
console.log("inside the function");
const classes = useStyles();
return (
<div className={classes.maindiv}>
<Typography variant="h5">this is it</Typography>
</div>
);
}
您的“排版”导入是错误的。 使用 import {Typography} from '@material-ui/core'; 而不是从“material-ui/styles/typography”导入排版;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.