简体   繁体   中英

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'; instead of import Typography from "material-ui/styles/typography";

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

Related Question 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 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 - 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