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

feat: Ionic 4 / React - Enable use of HashRouter in IonReactRouter #19621

Closed
tpperlman opened this issue Oct 10, 2019 · 13 comments
Closed

feat: Ionic 4 / React - Enable use of HashRouter in IonReactRouter #19621

tpperlman opened this issue Oct 10, 2019 · 13 comments
Labels
package: react @ionic/react package

Comments

@tpperlman
Copy link

Feature Request

Ionic version:
[x] 4.x

Describe the Feature Request
Please allow the IonReactRouter tag to also support HashRouter. As of now, BrowserRouter is hard-coded in as the default router scheme.

Describe Preferred Solution
Please add a parameter to the IonReactRouter tag that allows developers to choose HashRouter instead of the default BrowserRouter.

Describe Alternatives
If adding a parameter to IonReactRouter isn't feasible, a separate IonReactHashRouter tag could be created, but that would require redundant code to be maintained.

Additional Context
In some circumstances, hash-based routing is a better solution than HTML5-based browser routing. Hash routing is also more widely supported on older devices for backward compatibility. The stack overflow post at https://stackoverflow.com/questions/51974369/hashrouter-vs-browserrouter has some good background on use cases.

@ionitron-bot ionitron-bot bot added the triage label Oct 10, 2019
@elylucas elylucas added the package: react @ionic/react package label Oct 11, 2019
@ionitron-bot ionitron-bot bot removed the triage label Oct 11, 2019
@jamesopstad
Copy link

Was about to open the same issue because of new behaviour in IOS 13. PWAs in IOS 13 have a popover that appears when the URL changes. This obscures the top content on the page. Pressing 'Done' in the popover returns to the original URL. This has clearly been introduced because a change of URL is considered a move away from the app. Replacing BrowserRouter with HashRouter solves this issue and may therefore be better as the default setting.

@akshatbhargava123
Copy link

Can I pick this up?

@elylucas
Copy link
Contributor

@jamesopstad do you know of any documentation (from apple or otherwise), that discusses that popover?

@jamesopstad
Copy link

I don't I'm afraid. This was just my experience after upgrading iOS.

@tpperlman
Copy link
Author

@jamesopstad I tried one of my dev PWA apps on an iPhone 7 with iOS 13.1.2 and I don't see any popovers when I run it in safari. Perhaps you need to updated your react-router code or open a separate issue if it persists.

Either way, I hope we can get HashRouter added to IonReactRouter.

@jamesopstad
Copy link

To clarify, when I say PWA I mean that I've added the app to the home screen and opened it from there. Is that what you did? Also, I'm using an iPad so technically I'm using iPadOS now. Now there is some divergence it's possible the behaviour is different on an iPhone.

@iagobruno
Copy link

This can also be useful when we don't have a server and want the app to be mounted on one page. With BrowserRouter if the user shares or reloads the page a 404 error will appear, but with HashRouter this does not happen.

@elylucas
Copy link
Contributor

Coming soon in the 4.11.2 release, there will be an additional that uses react routers HashRouter.

@elylucas
Copy link
Contributor

Hi all,

We've added an IonReactHashRouter (exported from @ionic/react-router) that uses HashRouter and can be used in IonReactRouter's place.

We are also looking into the issue with the popover on iOS as well, as that should not be happening with the regular router.

Thanks

@tpperlman
Copy link
Author

Fantastic @elylucas, thank you for the enhancement. I look forward to the next release!

@HeyGarrison
Copy link

@elylucas is there an issue that I can track to monitor updates on the popover issue on iOS?

@elylucas
Copy link
Contributor

elylucas commented Nov 5, 2019

@GarrisonS its been a couple of weeks since I looked, but I wasn't able to find anything about it then. I'm wanting to check to see if it's still an issue in 13.2.

@ionitron-bot
Copy link

ionitron-bot bot commented Dec 5, 2019

Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out.

@ionitron-bot ionitron-bot bot locked and limited conversation to collaborators Dec 5, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
package: react @ionic/react package
Projects
None yet
Development

No branches or pull requests

6 participants