Reputation: 173
i'm using browser history and here is my code in routes.js
export default (
<Router history={browserHistory}>
<Route path="/" component={Main}>
<Route path="home/:username" component={Home}>
<IndexRoute component={HomeContent}></IndexRoute>
<Route path="widget/:second" component={Widget}></Route>
<Route path="email/:second" component={Email}>
<Route path="compose" component={ComposeEmail}></Route>
<IndexRoute component={CheckEmail}></IndexRoute>
</Route>
<Route path="social/:second" component={Social}></Route>
<Route path="calendar/:second" component={Calendar}></Route>
</Route>
<IndexRoute component={Login}></IndexRoute>
</Route>
</Router>
);
and i used this.context.router.push('/') to make a navigation. and i have no idea why this warning is keep showing in my console?
"Warning: [react-router] `Router` no longer defaults the history prop to hash history. Please use the `hashHistory` singleton instead."
i already read the documentation at https://github.com/reactjs/react-router/blob/master/upgrade-guides/v2.0.0.md#no-default-history but it does not really help.
i appreciated any help :)
Upvotes: 6
Views: 784
Reputation: 183
You need to use hashHistory
instead of browserHistory
. Considering you're using the import
synthax you can import hashHistory
from react-router
to replace browserHistory
.
import { hashHistory, Router, ... } from 'react-router';
const history = new hashHistory();
export default (
<Router history={history}>
...
</Router>
);
Upvotes: 0