HiveBrain v1.2.0
Get Started
← Back to all entries
debugjavascriptreactCritical

Uncaught Error: Invariant Violation: Element type is invalid: expected a string (for built-in components) or a class/function but got: object

Submitted by: @import:stackoverflow-api··
0
Viewed 0 times
uncaughterrorgotobjectbuiltfunctionexpectedclassforinvariant

Problem

I am getting this error:

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.

This is my code:

var React = require('react')
var ReactDOM =  require('react-dom')
var Router = require('react-router')
var Route = Router.Route
var Link = Router.Link

var App = React.createClass({
  render() {
    return (
      
        App
        
          About
        
      
    )
  }
})

var About = require('./components/Home')
ReactDOM.render((
  
    
      
    
  
), document.body)


My Home.jsx file:

var React = require('react');
var RaisedButton = require('material-ui/lib/raised-button');

var Home = React.createClass({
  render:function() {
    return (
        
    );
  },
});

module.exports = Home;

Solution

In my case (using Webpack) it was the difference between:

import {MyComponent} from '../components/xyz.js';


vs

import MyComponent from '../components/xyz.js';


The second one works while the first is causing the error. Or the opposite.

Context

Stack Overflow Q#34130539, score: 1267

Revisions (0)

No revisions yet.