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
What is the new or updated feature that you are suggesting?
For the HashRouter, it should be possible to start the location.hash with # instead of #/. To this end, I request the ability to serialize relative location instead of absolute location.
PR #8460 supports writing the relative path in the URL, configured to take effect when the Routerbasename property is given as "", instead of the default of "/".
After PR #8460, using <HashRouter basename=""> results in urls like this:
example.com/#
example.com/#abc
example.com/#1/2/3
I've created a codepen to compare the current behavior of <HashRouter basename=""> for the current V6 of react-router-dom and my PR #8460
Why should this feature be included?
In react-router-dom@v5, it was once possible to append directly after # with hashType="noslash". The hashType property of createHashHistory was available in history@4, but lost in history@5, so the additional configuration it afforded the HashRouter was removed in react-router-dom@6 with no replacement.
In react-router-dom@6, there is no possibility of hashType="noslash", so I propose we implement it whenever the user provides basename="". The other missing hashType of hashType="hashbang" could also supported with basename="!#", but that might be a separate issue.
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 #/.
The text was updated successfully, but these errors were encountered:
This could now be addressed with PR #8463 and remix-run/historyPR #911. My previous PR #8460 was closed, but I'm hopeful the new PRs will also be considered.
What is the new or updated feature that you are suggesting?
For the
HashRouter
, it should be possible to start thelocation.hash
with#
instead of#/
. To this end, I request the ability to serialize relative location instead of absolute location.PR #8460 supports writing the relative path in the URL, configured to take effect when the
Router
basename
property is given as""
, instead of the default of"/"
.UPDATE:
This is now possible with
[email protected]
anduse-hash-history
. I hope it will be soon available with an upcoming release ofhistory
through PR #911.Examples
When using
HashRouter
, the default basename is"/"
. This results in urls like this:After PR #8460, using
<HashRouter basename="">
results in urls like this:I've created a codepen to compare the current behavior of
<HashRouter basename="">
for the current V6 of react-router-dom and my PR #8460Why should this feature be included?
In react-router-dom@v5, it was once possible to append directly after
#
withhashType="noslash"
. ThehashType
property ofcreateHashHistory
was available in history@4, but lost in history@5, so the additional configuration it afforded theHashRouter
was removed inreact-router-dom@6
with no replacement.In
react-router-dom@6
, there is no possibility ofhashType="noslash"
, so I propose we implement it whenever the user providesbasename=""
. The other missing hashType ofhashType="hashbang"
could also supported withbasename="!#"
, but that might be a separate issue.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#/
.The text was updated successfully, but these errors were encountered: