我如何保持 react-redux 状态? [英] How do I maintain react-redux state?

查看:65
本文介绍了我如何保持 react-redux 状态?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用 react-redux,所有数据都包含在存储中.我如何维护存储在我们商店中的状态,例如,从父页面打开多个子标签或在页面刷新后?

With react-redux all the data is contained in the store. How can I maintain the state that is stored in our store when, for example, opening multiple child tabs from a parent page or after a page refresh?

推荐答案

redux-localstorage-simple 包可以满足您的需求.它是一个 redux 中间件组件,它会在启动时自动将 redux 状态序列化到本地存储并恢复该状态,作为 redux 初始数据.

The redux-localstorage-simple package does what you require. It is a redux middleware component that will automatically serialize redux state to local storage and restore that state, as redux initial-data, on startup.

该包还支持它存储的 redux 状态树的命名空间,因此这应该允许您在创建新选项卡时克隆不同的状态树.

The package also supports namespaces for the redux state trees it stores so this should allow you to clone distinct state-trees when creating new tabs.

这篇关于我如何保持 react-redux 状态?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆