History: Add state to hash history

Created on 30 May 2019  路  6Comments  路  Source: ReactTraining/history

I'm currently in a similar position to that mentioned by @matthewrobb in #435, where I am limited to using the hash portion of the url for my dynamic application routing but I'm not limited in my support for older browsers and want to make use of storing state in the navigation whilst using hash urls.

I know #435 mentions a few workarounds to use browserHistory and basename but those workarounds feel like a bit of a hack and won't really work for me.

I am going to be putting together my own version of hashHistory that uses the browser history API and I was wondering if there would be any interest in adding that within to this library. I'd be happy to submit a PR to do it, but would need a bit of guidance on what approach to take here and what would need to be supported.

feature

Most helpful comment

Quick update here: we are planning on adding this feature in version 5.

All 6 comments

I discussed this a bit with @mjackson a few months ago and I believe that a future version of history will support state with hash histories (by dropping old browser support and using the History API), but I am not privy to when this will happen.

Yes, but it will have to happen in a future major version. We need to bump our browser support to be only browsers that support pushState. Then we can add state to hash history because it will use pushState under the hood.

Quick update here: we are planning on adding this feature in version 5.

Heads up: in the v5 beta released today you can now use state with hash history. Please give it a shot and LMK how it goes!

I've tried updated our project with it, removing my own simple implementation we've had for the last few months - I can see the browser state working correctly. I've got a couple of issues but I think they're to do with relative paths so I think it's looking good 馃憤

Thanks for doing this!

Pretty awesome this is finally happening guys!

Even if it's after that project has long since ended and I don't do much React anymore :)

_(*reserves package name svelte-react-router)_

Was this page helpful?
0 / 5 - 0 ratings