如何在不同的 URL 路由之间保存 redux 状态?
How to save redux state between different URL routes?
我在 www.infinity2o.com 有一个 react/redux webapp,有多个路由:
<Route exact={true} path="/profile" component={Profile} />
<Route exact={true} path="/sorting_hat" component={SortingHat} />
我遇到的问题是我的 UI 颜色主题保存到我的 redux 商店中。但是每次我的 URL 路线从 infinity2o.com/profile
变为 infinity2o.com/sorting_hat
时,我的整个状态都会重置为 null
。
是否可以在路由之间切换时保持我的某些 redux 状态持久化?
你可以尝试使用 redux-persist 库
我在 www.infinity2o.com 有一个 react/redux webapp,有多个路由:
<Route exact={true} path="/profile" component={Profile} />
<Route exact={true} path="/sorting_hat" component={SortingHat} />
我遇到的问题是我的 UI 颜色主题保存到我的 redux 商店中。但是每次我的 URL 路线从 infinity2o.com/profile
变为 infinity2o.com/sorting_hat
时,我的整个状态都会重置为 null
。
是否可以在路由之间切换时保持我的某些 redux 状态持久化?
你可以尝试使用 redux-persist 库