Search code examples
reactjsreduxreact-reduxreact-router-dom

How to save redux state between different URL routes?


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?


Solution

  • you can try using redux-persist library