简体   繁体   English

如何维持react-redux状态?

[英]How do I maintain react-redux state?

With react-redux all the data is contained in the store. 使用react-redux,所有数据都包含在存储中。 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? 例如,当从父页面打开多个子选项卡或页面刷新后,如何保持存储在商店中的状态?

The redux-localstorage-simple package does what you require. redux-localstorage-simple软件包可以满足您的需求。 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中间件组件,它将在启动时自动将redux状态序列化到本地存储,并将该状态恢复为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. 该软件包还支持其存储的redux状态树的名称空间,因此在创建新标签时,这应允许您克隆不同的状态树。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM