-
-
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
Question: handling browser back button #967
Comments
in createClass spec using the navigation mixin onBackButtonEvent:(e) => {
e.preventDefault();
this.goBack();
}
componentDidMount: () => {
window.onpopstate = this.onBackButtonEvent;
} |
awesome. var ChatRoom = React.createClass({
mixins: [State, Navigation],
onBackButtonEvent: function (e) {
debug('handling back button press')
e.preventDefault()
this.transitionTo('chatrooms')
},
componentDidMount: function() {
window.onpopstate = this.onBackButtonEvent
},
render: function() {
return (
// jsx
)
}
})
module.exports = ChatRoom |
In this document says, the popstate event is not cancellable.
|
|
Do we still need to listen to |
|
@probablycorey unless otherwise noted, it's the same |
I'm developing for mobile so getting the back button working is pretty important.
I found you can detect it with
it's passed an event with the following format
![screenshot 2015-03-18 13 08 09](https://cloud.githubusercontent.com/assets/587438/6718282/daae46da-cd6f-11e4-9876-db11a606acda.png)
Any ideas how I can hook this object up to react-routers state management? I think it'd be great to just call whatever code is called when a
Link
component is clicked.The text was updated successfully, but these errors were encountered: