react-router
react-router copied to clipboard
fix: replace beforeunload to pagehide for safafi on ios
Fixes #9463
here is the codesandbox please check it in safari on ios
beforeunload event does not occur in safari on ios
Apple's documentation says to use pagehide instead of unload.
unloadDeprecated, usepagehideinstead.
the mdn documentation says
When the user clicks the browser's back button, the page hide event is fired on the current page before the previous page is displayed.
So I think it would be okay to use pagehide instead of beforeunload.
This is my first time working in react-router's codebase. Please let me know if there are any additional considerations
🦋 Changeset detected
Latest commit: 29077f4e7c61b48991255cf02bc663089f3c661e
The changes in this PR will be included in the next version bump.
This PR includes changesets to release 4 packages
| Name | Type |
|---|---|
| react-router-dom | Patch |
| react-router | Patch |
| react-router-dom-v5-compat | Patch |
| react-router-native | Patch |
Not sure what this means? Click here to learn what changesets are.
Click here if you're a maintainer who wants to add another changeset to this PR
Thank you for signing the Contributor License Agreement. Let's get this merged! 🥳
Thanks @jakkku! We can't change useBeforeUnload directly since that would be a breaking change, but we can look into using the pagehide event inside <ScrollRestoration>. I'm going to merge this into a branch of mine to make those changes and do some testing.