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:
JavaScript
x
10
10
1
import React from 'react';
2
import ReactDOM from 'react-dom';
3
import { Router, browserHistory } from 'react-router';
4
import routes from './routes';
5
6
ReactDOM.render(
7
<Router history={browserHistory} routes={routes} />,
8
document.getElementById('root')
9
);
10
Advertisement
Answer
You need to get browserHistory
from the history module now.
JavaScript
1
2
1
import createHistory from 'history/createBrowserHistory'
2
Note that they changed the module API recently so if you are using the latest version the import slightly changed:
JavaScript
1
2
1
import { createBrowserHistory } from 'history'
2