SyndicatorBBB SyndicatorBBB - 1 year ago 207
React JSX Question

React-Router - Uncaught TypeError: Cannot read property 'getCurrentLocation' of undefined

I'm using the latest version of react-router (version ^3.0.0).

I wrote the following routing using ES5:


var React = require("react");
var Router = require("react-router");
var AuthorPage = require('./components/authors/authorPage')
var App = require('./components/app')
var Route = Router.Route;

var routes = (
<Route path="/" component={App}>
<Route path="authors" component={AuthorPage}/>

module.exports = routes;

In other JS file called main.js I preform the following call:


var React= require("react");
var ReactDom = require("react-dom");
var Router = require('react-router').Router;
var routes = require('./routes');
ReactDom.render(<Router routes={routes}></Router>, document.getElementById('app'));

When I run the code I get the following exception in google chrome developer tools:

Uncaught TypeError: Cannot read property 'getCurrentLocation' of

Why is that? What am I missing?

Thank you

Answer Source

You are not passing a history to your <Router>.

Check out the histories documentation for more information.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download