Skip to content
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

[Bug]: Navigate(-1) not working in safari 16.* #9798

Closed
mseyfayi opened this issue Dec 31, 2022 · 2 comments
Closed

[Bug]: Navigate(-1) not working in safari 16.* #9798

mseyfayi opened this issue Dec 31, 2022 · 2 comments
Labels

Comments

@mseyfayi
Copy link

What version of React Router are you using?

6.6.1

Steps to Reproduce

  1. Use BrowserRouter as your router.
  2. Create a button and set its onClick to () => navigate(-1).
  3. Build the project in production mode.
  4. Open app with the Safari iOS 16.
  5. Click on button

Expected Behavior

URL should change and the page's content should change.

Actual Behavior

URL will change but the content will not update, and by a reload the state will fix.

The source of the bug is that safari 16 will not support the popstate event properly, it only triggers on page load when we are using react (SPA), so it's useless.
This problem will cause handlePop not to trigger and the state of BrowserRouter will not update.

@mseyfayi mseyfayi added the bug label Dec 31, 2022
@mseyfayi
Copy link
Author

mseyfayi commented Jan 3, 2023

Update:
I noticed that I have some <script async ... /> (like google analytics) in my HTML file and until these scripts are not downloaded popstate will not work.
In my case, I moved injected these scripts in an useEffect, so they will inject into DOM after the whole DOM is rendered and problem fixed

@brophdawg11
Copy link
Contributor

Sounds like this was an unrelated issue? Is it ok to close this out?

@mseyfayi mseyfayi closed this as completed Jan 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants