why createHashHistory is "for use in legacy web browsers"?

why createHashHistory is "for use in legacy web browsers"? (https://github.com/ReactTraining/history) How createBrowserHistory is better for SPA route management?
You already invited:

Amos

Upvotes from:

Well, browserhistory uses the pushState API, so there actually is a real state in the location
for example, I use it in an app between the pages "basket" and "checkout". In basket, user selects some items. Then proceeds to checkout with those. I set the IDs of selected values in the state of the location - but I do not show them in the URL.
Still, if you F5/refresh in checkout page - the IDs are still there
..first I had them in the URL, but user could do too much crazy things, and I had to handle too many error cases
browser history helped me there

Daryl k

Upvotes from:

well it's not hard, really. if you have apache server, it's as easy as this:
# BEGIN SINGLE PAGE REWRITE
RewriteEngine On
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -f [OR]
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -d
RewriteRule ^ - [L]
RewriteRule ^ /index.html [L]
# END SINGLE PAGE REWRITE

(in file .htaccess in server root)
it means: When a request comes, check if there is a correspronding file on the server. If there is, hand it out.
If there isn't , rewrite to index.html
And for nginx it's probably just a one-liner in config, not sure.
 

If you wanna answer this question please Login or Register