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] Missing hashType={"noslash"} of HashRouter #953

Open
letanloc1998 opened this issue May 29, 2022 · 3 comments
Open

[v6] Missing hashType={"noslash"} of HashRouter #953

letanloc1998 opened this issue May 29, 2022 · 3 comments

Comments

@letanloc1998
Copy link

letanloc1998 commented May 29, 2022

Hi,

I see HashRouter on v6 can't use hashType={"noslash"}.

If I use BrowserRouter, a host must fallback from 404 to index and it takes long time (I deployed my code on gitlab page and it takes 1.5s to processor).

However, HashRouter on v6 can't handle link /#*, it only hanle link /#/*. Eg: if I go to /#notExistLink, it doesn't redirect to not found route.

Does any one have solution to fix this issue?

Thanks.


.gitlab-ci.yml

image: alpine:latest

pages:
    stage: deploy
    script:
        - mkdir .public
        - cp -r ./* .public
        - rm -rf public
        - mv .public public

        # Support React Router for Gitlab Page
        - cp public/index.html public/404.html
    artifacts:
        paths:
            - public
    rules:
        - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
@thejohnhoffer
Copy link

thejohnhoffer commented Oct 18, 2022

I have waited on the merger of PR #911 for a while. As a workaround, I have created use-hash-history, which provides a Proxy around history in <200 lines of typescript.

  • hashType: "noslash" is possible in my proxy with hashRoot: ""
  • hashType: "hashbang" is achieved with hashRoot: "!/"

@thejohnhoffer
Copy link

thejohnhoffer commented Oct 18, 2022

It seems this issue may go unaddressed because this rejected issue is not a concern for react-router. It seems history exists primarily to serve React Router, according to @mjackson:

The goal with history v5 is to make this library just an implementation detail of React Router v6

@ryanflorence declared this issue was not a priority for React Router:

Thanks but we'll keep the / :)

@timdorr confirmed that:

As Ryan mentioned, this isn't going to be implemented

This feature would be nice to have, but Remix is paid to do things, and keeping "backwards support" for prettier URLs might not serve their goals as an organization at the moment.

Other related issues:

@chazlm
Copy link

chazlm commented Dec 20, 2022

does this work with react-router-dom@6.5.0?

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

3 participants