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

Error when trying to use Card #2649

Closed
matt1as opened this issue Dec 24, 2015 · 4 comments
Closed

Error when trying to use Card #2649

matt1as opened this issue Dec 24, 2015 · 4 comments
Labels
component: card This is the name of the generic UI component, not the React module!

Comments

@matt1as
Copy link

matt1as commented Dec 24, 2015

When trying to using Cards from the example page I get the following error
Error: Invariant Violation: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. Check the render method of Classified.

My code is

import React from 'react';
import ClassifiedStore  from '../stores/ClassifiedStore';
import connectToStores  from 'fluxible-addons-react/connectToStores';
import { Card, CardHeader, CardMedia, CardTitle, CardText, Avatar , CardActions, FlatButton} from 'material-ui/lib/card/card';

class Classified extends React.Component {
    render() {
      var classified = this.props.classified;
        return (
          <div>
          <Card>
            <CardHeader
              title="Title"
              subtitle="Subtitle"
              avatar={<Avatar>A</Avatar>}/>
            <CardHeader
              title="Demo Url Based Avatar"
              subtitle="Subtitle"
              avatar="http://lorempixel.com/100/100/nature/"/>
            <CardMedia overlay={<CardTitle title="Title" subtitle="Subtitle"/>}>
              <img src="http://lorempixel.com/600/337/nature/"/>
            </CardMedia>
            <CardTitle title="Title" subtitle="Subtitle"/>
            <CardActions>
              <FlatButton label="Action1"/>
              <FlatButton label="Action2"/>
            </CardActions>
            <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.
            </CardText>
          </Card>
          </div>
        );
    }
};

module.exports = connectToStores(
    Classified,
    [ClassifiedStore],
    function (context, props) {

        return {
            classified: context.getStore(ClassifiedStore).get(),
        }
    }
);

@c0b41
Copy link

c0b41 commented Dec 24, 2015

need theme context
http://www.material-ui.com/#/customization/themes

  1. Using React Lifecycle Methods with Context

or

  1. Using ES7-style Decorator

@matt1as
Copy link
Author

matt1as commented Dec 25, 2015

But why do I need theme context, I'm not using a custom theme, and it's not mentioned in any documentation I have seen.

@alitaheri
Copy link
Member

@matt1as I don't think its related to theme. Could you try to find out exactly which one of these component is causing that error? I don't think it's related to Card

@oliviertassinari
Copy link
Member

Your import is wrong, please use stackoverflow for this type of question.

import { Card, CardHeader, CardMedia, CardTitle, CardText, Avatar , CardActions, FlatButton} from 'material-ui/lib/card/card';

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

5 participants