I need to redirect to home page when user refreshes other pages inside my application. I am using React router
v4 and redux
. Since the store is lost on reload, the page user reloaded is now empty and hence I want to take him back to a page that does not need any previous stored data. I don't want to retain state in localStorage
.
I tried to handle this in event onload
but it did not work:
window.onload = function() {
window.location.path = '/aaaa/' + getCurrentConfig();
};
It is so amazing that you don't want to keep state of user route map in browser but you use
react-router
!, the main solution for your case is do not usereact-router
.If you don't use it, after each
refresh
the app come back to main view of app, If you wanna see route map inaddress bar
without any reaction useJavaScript
history
pushState
.Hope it helps you.