Reputation: 41
I am using redux for state management and Vaadin router for SPA routing. If I invoke av new route by clicking a <a href="/charger">Go to charger view</a>
the charger view renders in the router outlet and state remains intact. The problem arise when I want to invoke a new route changing the adress field or changing as document.location.href = '/charger'
. In this case the redux store gets cleared. Does anyone know why and how to solv it?
Upvotes: 0
Views: 92
Reputation: 1186
Manually changing the address field or setting document.location.href
causes the browser to render the page from scratch. The only way to keep the state across those would be to persist the states in the redux store in a persistent storage like local storage or session storage.
There are libraries like redux-persist
that help you do this or you could write your own.
Upvotes: 1