Reputation: 1118
I am creating a project using reactjs.In my project i want to remove # from the url. Currently i am using the react-router version 4. here is my code
import { HashRouter as Router, Route,browserHistory } from 'react-router-dom';
<Router history={browserHistory} >
<App>
<Route path="/dashboard" component={Dashboard} />
<Route path="/revenue" component={RevenueReports} />
</App>
</Router>,
Upvotes: 0
Views: 4101
Reputation: 281666
browserHistory is not available in latest react-router-dom. However BrowserRouter
uses the default as browserHistory
and you could simply do
import { BrowserRouter as Router, Route } from 'react-router-dom';
<Router >
<App>
<Route path="/dashboard" component={Dashboard} />
<Route path="/revenue" component={RevenueReports} />
</App>
</Router>,
According to the docs:
A
BrowserRouter
is a<Router>
that uses the HTML5 history API (pushState, replaceState and the popstate event) to keep your UI in sync with the URL.
Upvotes: 1