我在 www.infinity2o.com 有一个有多个路由的 React/redux Web 应用程序:
<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 库
关于reactjs - 如何在不同的 URL 路由之间保存 redux 状态?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50884301/