Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Card] Invariant Violation #1991

Closed
jpilcher opened this issue Oct 26, 2015 · 2 comments
Closed

[Card] Invariant Violation #1991

jpilcher opened this issue Oct 26, 2015 · 2 comments
Labels
component: card This is the name of the generic UI component, not the React module!

Comments

@jpilcher
Copy link

Uncaught Error: Invariant Violation: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object. Check the render method of 'Presentation'.

I'm trying to use the Card element but I keep getting this error. I lifted the example from the documentation. I have an AppBar and LeftNav working fine, any insight into what I'm doing wrong is greatly appreciated.

import React from 'react';
import Card from 'material-ui/lib/card';
import FlatButton from 'material-ui/lib/flat-button';

class Presentation extends React.Component{
    constructor(props) {
        super(props);
    }

    render() {
        return (
            <Card>
                <Card.CardHeader
                    title="Demo Url Based Avatar"
                    subtitle="Subtitle"
                    avatar="http://lorempixel.com/100/100/nature/"/>
                <Card.CardMedia overlay={<Card.CardTitle title="Title" subtitle="Subtitle"/>}>
                    <img src="http://lorempixel.com/600/337/nature/"/>
                </Card.CardMedia>
                <Card.CardTitle title="Title" subtitle="Subtitle"/>
                <Card.CardActions>
                    <FlatButton label="Action1"/>
                    <FlatButton label="Action2"/>
                </Card.CardActions>
                <Card.CardText>
                    Lorem ipsum dolor sit amet, consectetur adipiscing elit.
                    Donec mattis pretium massa. Aliquam erat volutpat. Nulla facilisi.
                    Donec vulputate interdum sollicitudin. Nunc lacinia auctor quam sed pellentesque.
                    Aliquam dui mauris, mattis quis lacus id, pellentesque lobortis odio.
                </Card.CardText>
            </Card>
        )
    }
}

export default Presentation;
    "material-ui": "^0.13.0",
    "react": "^0.14.0",
    "react-addons-create-fragment": "^0.14.0",
    "react-addons-pure-render-mixin": "^0.14.0",
    "react-addons-transition-group": "^0.14.0",
    "react-addons-update": "^0.14.0",
    "react-dom": "^0.14.0",
    "react-tap-event-plugin": "^0.2.1"
@isilweo
Copy link

isilweo commented Oct 27, 2015

It is problem of your imports. material-ui/lib/card does not export CardHeader component only Card. CardHeader is in diffrent file - material-ui/lib/card-header

Why don't you do imports in normal way like:

import { Card, CardHeader, CardMedia, CardTitle, CardActions, CardText } from 'material-ui';

@jpilcher
Copy link
Author

Thanks! That fixed it. I had tried that but I must have had something else wrong I didn't notice. The file posted was after trying a bunch of things.

mnajdova pushed a commit to mnajdova/material-ui that referenced this issue Nov 10, 2020
@zannager zannager added the component: card This is the name of the generic UI component, not the React module! label Dec 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: card This is the name of the generic UI component, not the React module!
Projects
None yet
Development

No branches or pull requests

3 participants