Skip to content

Instantly share code, notes, and snippets.

@velopert
Last active August 31, 2016 14:27
Show Gist options
  • Save velopert/ab6e132d73a17930c90e3e38493c12ed to your computer and use it in GitHub Desktop.
Save velopert/ab6e132d73a17930c90e3e38493c12ed to your computer and use it in GitHub Desktop.
React: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined.

Directory Structure

./src
├── containers
│    ├── App.js
│    ├── UserInfo.js
│    └── index.js
└── index.js

src/containers/App.js

import React, { Component } from 'react';
import { UserInfo } from 'containers'; // or import { UserInfo } from './index';

class App extends Component {
  render() {
    return (
        <UserInfo/>
    );
  }
}

export default App;

src/containers/UserInfo.js

import React, { Component } from 'react';

class UserInfo extends Component {
  render() {
    return (
        <div>UserInfo</div>
    );
  }
}

export default UserInfo;

src/containers/index.js

import UserInfo from './UserInfo';
import App from './App';

export { UserInfo, App }

src/index.js

import React from 'react';
import ReactDOM from 'react-dom';

import { App } from 'containers'

ReactDOM.render(
  <App />,
  document.getElementById('root')
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment