remix-run / history

Manage session history with JavaScript
MIT License
8.29k stars 961 forks source link

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

Open letanloc1998 opened 2 years ago

letanloc1998 commented 2 years ago

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 commented 1 year ago

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.

thejohnhoffer commented 1 year ago

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 commented 1 year ago

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