Reputation: 563
I am trying to use react-router v2.0.0 and when I use import { Router, Route, browserHistory } from 'react-router'
and then console.log(Router)
I get that Router is undefined. However, when I log Route, it outputs the correct object.
"use strict";
import React from 'react'
import { Router, Route, browserHistory } from 'react-router'
import Home from './pages/home.js'
import Entrance from './pages/Entrance.js'
import Courses from './pages/Courses.js'
import Quizzes from './pages/Quizzes.js'
console.log("conner", Router);
console.log("conner", Route);
module.exports = (
<Router history={browserHistory}>
<Route path="/" component={Home}>
<Route path="entrance" component={Entrance} />
<Route path="courses" component={Courses} />
<Route path="quizzes" component={Quizzes} />
</Route>
</Router>
);
This all results in this console error: Uncaught Invariant Violation: ReactDOM.render(): Invalid component element. This may be caused by unintentionally loading two independent copies of React
What am I doing wrong?
Upvotes: 3
Views: 193
Reputation: 1193
If you go on the directory where you have your web project and you just type : npm ls | grep react .
If you see react appearing multiple times then you have dependencies problems as some modulues installed newer versions of react on top of an older version breaking everything.
You can try npm shrinkwrap, npm prune, fixing your package.json.
You can refer to this post about shrinkwrap: http://javascript.tutorialhorizon.com/2015/03/21/what-is-npm-shrinkwrap-and-when-is-it-needed/
Upvotes: 0
Reputation: 66
Did you go into your node_modules and into react-router to check its version in its package.json?
Upvotes: 1