'React.createElement: type is invalid' on running webpack-dev-server
I'm getting the following errors while running a webpack dev command to load my app files:
Warning: React.createElement: 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.
The error seems to come from bundle.js which is my bundled output from webpack though i checked to confirm i'm exporting all components.
react-router version: 4.1.1
npm script :
"dev": "cross-env NODE_ENV=development webpack-dev-server --config ./webpack/webpack.dev.js --hot --inline",
app.js
import React from 'react';
import ReactDOM from 'react-dom';
import { Router, Route, IndexRoute, browserHistory } from 'react-router';
import App from './containers/App.jsx';
import Home from './containers/Home.jsx';
import Login from './containers/Login.jsx';
import './styles/main.scss';
const renderApp = () => {
ReactDOM.render(
<Router history={ browserHistory }>
<Route path='/' component={ App } >
<IndexRoute component={ Login } />
<Route path='home' component={ Home } />
</Route>
</Router>,
document.getElementById('app'),
);
};
renderApp();
You're attempting to use React Router v3 components with React Router v4.
The simplest solution would be to downgrade your intalled version of React Router to v3.
If you are intending to use v4, I would recommend checking out the documentation website https://reacttraining.com/react-router/web/guides/quick-start
Oh silly me, thanks a bunch!