React-router: What API changes cause this two problem?

Created on 12 Mar 2017  路  5Comments  路  Source: ReactTraining/react-router

1.

Warning: Failed prop type: The prop `history` is marked as required in `Router`, but its value is `undefined`.

2.

Uncaught TypeError: Cannot read property 'listen' of undefined
    at syncHistoryWithStore

There are no error for 3.0.2 but for lastest.

Most helpful comment

@ashishrijal I had the same issue, and I was also blind to the fact that the new 4.0.0 imports from react-router-dom and not react-router.

import {BrowserRouter as Router, Route, Link} from "react-router-dom";

and not something like

import {Router, Route, Link} from "react-router";

which will cause weird error messages that seem unrelated. Hope this helps.

All 5 comments

The documentation is lacking.. there have been big changes, it seems, and v5.0.0-beta2 (iirc) removed syncHistoryWithStore, and needs a specific version of history..

I am having similar/same issues after updating my node modules:

Warning: Failed prop type: The prophistoryis marked as required inRouter, but its value isundefined. in Router

Uncaught TypeError: Cannot read property 'location' of undefined at new Router

I was having the same problem, i switched back to react-router version 3.0.2 and the issue was gone.May be there are some changes on the new version!

Hi @EasonWang01. React Router v4 is a complete re-write of React Router and therefor you shouldn't have the expectation of upgrading and still having everything work (which is why it's v4 and not v3.X). With that said, feel free to stick with the previous version (v3) if it's working for you. If you'd like to take the time to upgrade, you can read all about the new api here.

@ashishrijal I had the same issue, and I was also blind to the fact that the new 4.0.0 imports from react-router-dom and not react-router.

import {BrowserRouter as Router, Route, Link} from "react-router-dom";

and not something like

import {Router, Route, Link} from "react-router";

which will cause weird error messages that seem unrelated. Hope this helps.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Waquo picture Waquo  路  3Comments

jzimmek picture jzimmek  路  3Comments

ArthurRougier picture ArthurRougier  路  3Comments

hgezim picture hgezim  路  3Comments

nicolashery picture nicolashery  路  3Comments