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

ackvf picture ackvf  路  3Comments

hgezim picture hgezim  路  3Comments

nicolashery picture nicolashery  路  3Comments

maier-stefan picture maier-stefan  路  3Comments

stnwk picture stnwk  路  3Comments