-
-
Notifications
You must be signed in to change notification settings - Fork 10.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
hashHistory stopped working in 4.0.0 #4752
Comments
It has been moved to a new package, react-router-dom. Install the new package and follow the docs for HashRouter |
It's not clear how to use it from the docs. How to migrate this code for example:
|
The getting started guide might be more clear. Just replace BrowserRouter with HashRouter. You no longer need to pass the history as a prop anymore. So for your code it would be.
|
@timdorr question on this one: we are currently upgrading from R-router 2 to 4. In 2, we had a file where we used How can I do this with the new component |
@orangecoding you can still listen to history in react-router 4. class App extends React.Component {
componentDidMount() {
const { history } = this.props;
history.listen(e => {
console.log('listen', e.pathname);
});
}
render() {
...
}
}
...
ReactDOM.render(
<Provider store={store}>
<Router>
<Route component={App} />
</Router>
</Provider>,
document.getElementById('root')
); |
'react-router' does not contain an export named 'hashHistory'. why? |
@Anna098301065 The API in 4.0 was completely changed. Please read through the docs. |
}` Accordting to emjaksa, using HashRouter would solve the error. In my case, however, clicking Link (or NavLink) shows an error message |
Version
4.0.0
Test Case
the jsbin doesn't work because the library is too old, need 4.0.0
Steps to reproduce
Upgrade to 4.0.0
Expected Behavior
It should work
Actual Behavior
It doesn't work
The text was updated successfully, but these errors were encountered: