Skip to content

Remove need for #/ with HashRouter basename="" - #8460

Closed
thejohnhoffer wants to merge 2 commits into
remix-run:devfrom
thejohnhoffer:dev
Closed

Remove need for #/ with HashRouter basename=""#8460
thejohnhoffer wants to merge 2 commits into
remix-run:devfrom
thejohnhoffer:dev

Conversation

@thejohnhoffer

@thejohnhoffer thejohnhoffer commented Dec 9, 2021

Copy link
Copy Markdown

Closes issue #8459.

I've created a codepen to show the results of this PR against the latest release.

I've created a hook called useNavigator, which wraps the router's navigator object. This wrapping only occurs when basename="". This wrapped navigator serializes each pathname without the leading /. The difference can only be seen when <HashRouter basename="">.

The difference is that paths are written to the URL like #abc instead of #/abc.

@remix-cla-bot

remix-cla-bot Bot commented Dec 9, 2021

Copy link
Copy Markdown
Contributor

Thank you for signing the Contributor License Agreement. Let's get this merged! 🥳

1 similar comment
@remix-cla-bot

remix-cla-bot Bot commented Dec 9, 2021

Copy link
Copy Markdown
Contributor

Thank you for signing the Contributor License Agreement. Let's get this merged! 🥳

@thejohnhoffer thejohnhoffer changed the title Remove need for #/ with HashRouter basename="/" Remove need for #/ with HashRouter basename="" Dec 9, 2021
@remix-cla-bot

remix-cla-bot Bot commented Dec 9, 2021

Copy link
Copy Markdown
Contributor

Thank you for signing the Contributor License Agreement. Let's get this merged! 🥳

@remix-cla-bot

remix-cla-bot Bot commented Dec 9, 2021

Copy link
Copy Markdown
Contributor

Thank you for signing the Contributor License Agreement. Let's get this merged! 🥳

@ryanflorence

Copy link
Copy Markdown
Member

Thanks but we'll keep the / :)

@thejohnhoffer

Copy link
Copy Markdown
Author

This is now possible with react-router-dom@6.1.1 and history PR #911.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants