简体   繁体   English

错误:元素类型无效:应为字符串(对于内置组件)或类/函数(对于复合组件)但得到:对象

[英]Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object

I seem to be having a problem with this module that was exported in the correct manner but when it is imported and i get the error that was stated above.我似乎遇到了这个以正确方式导出的模块的问题,但是当它被导入时,我得到了上面提到的错误。 can anyone help?有人可以帮忙吗? anything is appreciated Here is the code of the module任何东西都值得赞赏这是模块的代码

    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>
      );
    }

Your 'Typography' import is wrong.您的“排版”导入是错误的。 Use import {Typography} from '@material-ui/core';使用 import {Typography} from '@material-ui/core'; instead of import Typography from "material-ui/styles/typography";而不是从“material-ui/styles/typography”导入排版;

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 错误:元素类型无效:预期为字符串(对于内置组件)或类/函数(对于复合组件)但得到:ReactJS 中的对象 - Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object in ReactJS × 错误:元素类型无效:需要一个字符串(对于内置组件)或一个类/函数(对于复合组件)但得到:object - × Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object 元素类型无效:应为字符串(对于内置组件)或类/函数(对于复合组件)但得到:object。abcd - Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object. abcd 不变违规:元素类型无效:预期为字符串(内置组件)或类/函数(复合组件),但得到:对象 - Invariant Violation: Element type is invalid: expected a string (built-in components) or a class/function (composite components) but got: object 错误 - 错误:元素类型无效:需要一个字符串(对于内置组件)或一个类/函数(对于复合组件)但得到:未定义 - error - Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined 错误:元素类型无效:需要一个字符串(对于内置组件)或一个类/函数(对于复合组件)但得到:未定义 - Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined 渲染错误元素类型无效:预期为字符串(对于内置组件)或类/函数(对于复合组件)但得到:未定义 - Render Error Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined 控制台错误:元素类型无效:预期为字符串(对于内置组件)或类/函数(对于复合组件)但得到:未定义 - Console error: Element type is invalid:expected a string (for built-in components) or a class/function (for composite components) but got: undefined React - 错误:元素类型无效:需要一个字符串(对于内置组件)或一个类/函数(对于复合组件)但得到:未定义 - React - Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined 未捕获的错误:元素类型无效:预期为字符串(内置组件)或类/函数(复合组件),但得到:未定义 - Uncaught Error: Element type is invalid: expected a string (built-in components) or a class/function ( composite components) but got: undefined
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM