2

I am using react-router-redux from this repo https://github.com/reacttraining/react-router/tree/master/packages/react-router-redux to route my application. But I always get below error in my browser console:

Uncaught Error: Element 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, or you might have mixed up default and named imports.

Below is the source code of App component. All these codes are the front end:

const history = createHistory();
const rMiddleware = routerMiddleware(history);
const logger = createLogger({
  log: 'info',
});

const store = compose(
  applyMiddleware(thunk, authMiddleware, rMiddleware, logger)
)(createStore)(combineReducers({...reducers, router: routerReducer}));

export default class App extends Component {
  render() {
    return (
      <Provider store={store}>
        <ConnectedRouter history={history}>
          <Switch>
              <Route exact path="/" component={Home} />
          </Switch>
        </ConnectedRouter>
      </Provider>
    );
  }
}

Below is the Home component code:

class Home extends React.Component {
  render() {
    return <div>Home</div>;
  }
}
const mapStateToProps = state => {
  return {
  };
};

const mapDispatchToProps = dispatch => {
  return {
  };
};
export default connect(mapStateToProps, mapDispatchToProps)(Home);
3
  • Can we see Home & Login? Commented Dec 18, 2017 at 4:18
  • I have updated the source code. Commented Dec 18, 2017 at 4:36
  • I'm currently on the react-router learning-curve. Always when I get this error it's a path mistake in my import statements (I'm using ES6 modules). You're not showing those here though. Commented Dec 18, 2017 at 4:48

1 Answer 1

3

Ok finally found out the issue. It because of a version miss-match. I should use "react-router-redux": "^5.0.0-alpha.9", instead of version 4.x.x since it is not compatible with react-router 4.x.x.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.