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

V5 Missing hashType="noslash" #912

Open
thejohnhoffer opened this issue Dec 10, 2021 · 2 comments
Open

V5 Missing hashType="noslash" #912

thejohnhoffer opened this issue Dec 10, 2021 · 2 comments

Comments

@thejohnhoffer
Copy link

thejohnhoffer commented Dec 10, 2021

The release of history@5 lost the ability to navigate a HashHistory without a slash in the hash (like #1/2/3 instead of #/1/2/3) due to a missing hashType option to createHashHistory.

After another user asked about the resulting loss of hashType in react-router-dom@6, one maintainer suggested we file in this repository. The solution developed in PR #911 would allow hashRoot="" to replicate the old behavior of hashType="noslash".

The ability to begin hashes with # instead of #/ is not only cosmetic. I am migrating an existing website from vanilla javascript to react, and backwards compatibility of existing URL hash values requires # instead of #/.

@thejohnhoffer
Copy link
Author

thejohnhoffer commented Dec 12, 2021

With react-router-dom@6.1.1, the parameter proposed for createHashHistory can take effect immediately, thanks to the prematurely released (as of now unstable) HistoryRouter API.

So, if PR #911 were released with history@next, the changes to history.createHashHistory could directly be used in react-router-dom@6.1.1 as follows:

<HistoryRouter basename="" history={createHashHistory({
  window, hashRoot: ""
})}>

Here is a short example I've written to integrate react-router-dom with a custom package called use-hash-history that hosts the hashRoot="" feature of PR #911.

@thejohnhoffer
Copy link
Author

@chaance do you see value in this feature? PR #911 has been ready to solve this for some time now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant