You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
componentDidMount(){
this.props.router.setRouteLeaveHook(
this.props.route,
this.routerWillLeave
)
routerWillLeave(nextLocation){
return 'Are you sure you want to leave?';
}
However, it's worst when I used it anyway on my 3.0.0 react SPA with browserHistory or hashHistory, as trying to navigate away by clicking links or back button not only doesn't trigger a leave prompt, the back button and any links on the page becomes malfunctioned as clicking on it has no effect at all, just like being trapped in those spam sites that forces you to stay.
I wonder what could be the solution? Would it be better to have something as follows implemented?
if ('onpagehide' in window) {
//if(window.onpagehide || window.onpagehide === null){
window.addEventListener('pagehide', exitFunction, false);
} else {
window.addEventListener('unload', exitFunction, false);
}
Ah, I just realized that this issue is talking about beforeunload. We don't actually currently support beforeunload in 4.x due to inconsistencies between the ways that browsers handle it. If you'd like support for it, I'd suggest you open a new issue in the history lib. As for now, it works as intended.
Version
3.0.0 + 4.0.0
For 3.0.0, I used this:
For 4.0.0, I simply tested with the example in https://react-router.now.sh/
I tested on iOS 10, with Chrome, Firefox, UC Browser, Opera Mini all working well.
The reason is most likely that Safari doesn't support
beforeunload
andpagehide
is used instead.https://developer.apple.com/library/content/documentation/AppleApplications/Reference/SafariWebContent/HandlingEvents/HandlingEvents.html
However, it's worst when I used it anyway on my 3.0.0 react SPA with
browserHistory
orhashHistory
, as trying to navigate away by clicking links or back button not only doesn't trigger a leave prompt, the back button and any links on the page becomes malfunctioned as clicking on it has no effect at all, just like being trapped in those spam sites that forces you to stay.I wonder what could be the solution? Would it be better to have something as follows implemented?
Source:
http://stackoverflow.com/questions/6906146/how-to-detect-browser-support-for-pageshow-and-pagehide
The text was updated successfully, but these errors were encountered: