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

Should it work fine if I'm using HashRouter? #175

Open
vcardins opened this issue Dec 10, 2020 · 4 comments
Open

Should it work fine if I'm using HashRouter? #175

vcardins opened this issue Dec 10, 2020 · 4 comments

Comments

@vcardins
Copy link

No description provided.

@Dean177
Copy link
Owner

Dean177 commented Dec 10, 2020

Yes, the router you use shouldn't have any impact on functionality/

Are you encountering unexpected behaviour

@vcardins
Copy link
Author

vcardins commented Dec 10, 2020

Hi Dean, thanks for the quick reply. Yes, I noticed that it removes the hash route:

I decorated my class component like
const MyPagePageWithUrlState = withUrlState(() => Utils.getSearchParams())(MyPage);

then when I click on a link to that page
http://localhost/#/page?&filter1=2190&filter2=2&filter3=q4...
it loads the page but replaces the URL to
http://localhost/?&filter1=2190&filter2=2&filter3=q4#/page (not the har route it was to the end)

Any advice?

@Dean177
Copy link
Owner

Dean177 commented Dec 10, 2020

Are you using the v1.0.0-alpha.0? If not, perhaps give that a shot first.

If the newer version isn't working either you can pass a history object as a config parameter, it needs to have the following signature:

type UnregisterCallback = () => void

export type HistoryAdapter = {
  listen: (listener: () => void) => UnregisterCallback
  location: Location
  push: (location: Location) => void
  replace: (location: Location) => void
}

// Maybe your hash router has a compatible API that would let you use it like so:
let hashHistory = {
  listen: (listener) => hashRouter.listen(listener)
  location: hasRouter.location,
  push: (location) => hashRouter.push(location)
  replace: (location) => hashRouter.replace(location)  
}

What are you using for routing?

@vcardins
Copy link
Author

Thanks, Dean! I'll try that. I'm using React Router 5.1.2.

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

2 participants