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

[v6] HashRouter 'hashType' prop is no longer supported #7703

Closed
tannera opened this issue Nov 27, 2020 · 6 comments
Closed

[v6] HashRouter 'hashType' prop is no longer supported #7703

tannera opened this issue Nov 27, 2020 · 6 comments

Comments

@tannera
Copy link

tannera commented Nov 27, 2020

Version

6.0.0-beta.0

Test Case

Example working with Version 5.2: https://codesandbox.io/s/brave-bouman-xye62?file=/src/App.js
Example with 6.0 beta.0: https://codesandbox.io/s/friendly-wood-5tj4f?file=/src/App.js

Steps to reproduce

Using <HashRouter/> with the hashType="noslash" prop does not work in v6, only the default slash behaviour is supported in v6.

  <HashRouter hashType="noslash">
    <Routes basename="test">
      <Route path="/">
        <Home />
      </Route>
    </Routes>
  </HashRouter>

Expected Behavior

hashType prop would be supported just like in version 5.1 as described in https://github.com/ReactTraining/react-router/blob/master/packages/react-router-dom/docs/api/HashRouter.md#hashtype-string

There are no notices about hashType being deprecated anywhere.

Actual Behavior

always behaves as with <HashRouter hashType="slash"/> which was the default behaviour.

@timdorr
Copy link
Member

timdorr commented Nov 28, 2020

Router v6 is based on History v5, which removes hashType. If you want it back, you would need to ask over there first: https://github.com/ReactTraining/history/ However, be warned that it was specifically removed in v5, so it's not likely to return.

@thejohnhoffer
Copy link

thejohnhoffer commented Dec 7, 2021

This is a request to reconsider this issue. The old v5 API of HashRouter allows hashes to begin as # rather than #/. A UI I'm migrating to React has a requirement that the hash be of the form #a=x#b=y#c=z, so I restored the v5 API behavior for a component constructed with:

<HashRouter hashType="noslash"/>

I've opened a PR (#8450) that allows hashType="noslash", and I'm happy to improve or clean up the solution to meet the contributors' standards for inclusion in a minor version release.

UPDATE:

This is now possible with [email protected] and use-hash-history. I hope it will be soon available with an upcoming release of history through PR #911.

@fnick851
Copy link

fnick851 commented Dec 21, 2021

@thejohnhoffer I'm using "react-router-dom": "^6.2.1" and this feature is not available. I guess it hasn't made its way into react-router yet?

UPDATE:
I see it is available via your package - life saver, thanks!

@thejohnhoffer
Copy link

thejohnhoffer commented Dec 21, 2021

@thejohnhoffer I'm using "react-router-dom": "^6.2.1" and this feature is not available. I guess it hasn't made its way into react-router yet?

UPDATE: I see it is available via your package - life saver, thanks!

I'm happy you're using it @fnick851. Please let me know of any issues you're facing.

For anyone else, here is a template you can use for now..

You can use use-hash-history and [email protected]. It also works fine with [email protected].

@chazlm
Copy link

chazlm commented Dec 20, 2022

is this workaround still required for [email protected]?

@chazlm
Copy link

chazlm commented Dec 21, 2022

@thejohnhoffer I'm looking to use use-hash-history but implementation isn't clear, are you able to assist?

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

5 participants