Reputation: 15405
I have a react/redux webapp at www.infinity2o.com with multiple routes:
<Route exact={true} path="/profile" component={Profile} />
<Route exact={true} path="/sorting_hat" component={SortingHat} />
The problem I'm having is that my UI color theme is saved into my redux store. But every time my URL route changes like from infinity2o.com/profile
to infinity2o.com/sorting_hat
my entire state gets reset to null
.
Is it possible to keep some of my redux state persistent when switching between routes?
Upvotes: 2
Views: 936
Reputation: 1
You can save your state in local storage using localStorage.setItem("key", "value"). And set your initial redux state from local storage using localStorage.getItem("key")
Upvotes: 0