Material-ui: Element type is invalid: expected a string (for built-in components) or a

Created on 21 Jul 2018  路  3Comments  路  Source: mui-org/material-ui

I'm trying to help someone out here. I went down this rabbit hole:

https://stackoverflow.com/questions/34130539/uncaught-error-invariant-violation-element-type-is-invalid-expected-a-string

keywords : Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.

This is the problem when you're gluing too many things together and being cavalier with versions. I updated a version of material-ui and need to change

import Card, {CardContent, CardMedia, CardActions } from "@material-ui/core/Card";

to this:

import Card from '@material-ui/core/Card';
import CardActions from '@material-ui/core/CardActions';
import CardContent from '@material-ui/core/CardContent';
import CardMedia from '@material-ui/core/CardMedia';

Watch your versions!!!

Most helpful comment

just leaving this to try to help...

All 3 comments

just leaving this to try to help...

That was killing me on the ListItem

I had this too when renaming imports:

import  * as MuiCard from '@material-ui/core/Card';
import CardActions from '@material-ui/core/CardActions';
import * as MuiCardContent from '@material-ui/core/CardContent';
import CardMedia from '@material-ui/core/;

Versions:

    "@material-ui/core": "^4.4.0",
    "@material-ui/styles": "^4.3.3",
Was this page helpful?
0 / 5 - 0 ratings