React-router: 'react-router' does not contain an export named 'browserHistory'

Created on 20 Jun 2017  路  2Comments  路  Source: ReactTraining/react-router

import {browserHistory} from 'react-router'銆俠ut throw the error that browserHistory does not exist..and Cannot read property 'location' of undefined

Most helpful comment

There is no browserHistory export in v4. If you're using v2/3, then you just need to install the correct version (npm install react-router@3). If you are using v4, you should read this section of the migration guide.

All 2 comments

There is no browserHistory export in v4. If you're using v2/3, then you just need to install the correct version (npm install react-router@3). If you are using v4, you should read this section of the migration guide.

Also you can refer 'A Simple React Router v4 Tutorial'

https://medium.com/@pshrmn/a-simple-react-router-v4-tutorial-7f23ff27adf

Where you need to install 'npm install react-router-dom --save' in your project directory and
then you can include following

import { BrowserRouter, Link, Route } from 'react-router-dom';

Example :
react-router-v4-example

Is working fine for me.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

nicolashery picture nicolashery  路  3Comments

andrewpillar picture andrewpillar  路  3Comments

ArthurRougier picture ArthurRougier  路  3Comments

jzimmek picture jzimmek  路  3Comments

winkler1 picture winkler1  路  3Comments