Skip to content
Advertisement

React router not showing browser history

I’m learning from this tutorial but I keep getting this error:

‘react-router’ does not contain an export named ‘browserHistory’.

The file that has react-router is this:

import React from 'react';
import ReactDOM from 'react-dom';
import { Router, browserHistory } from 'react-router';
import routes from './routes';

ReactDOM.render(
  <Router history={browserHistory} routes={routes} />, 
  document.getElementById('root')
);

Advertisement

Answer

You need to get browserHistory from the history module now.

import createHistory from 'history/createBrowserHistory'

Note that they changed the module API recently so if you are using the latest version the import slightly changed:

import { createBrowserHistory } from 'history'
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement