简体   繁体   English

如何使用redux-persist仅存储redux状态的一部分

[英]How to store only a part of the redux state using redux-persist

How can I store only a part of the redux-state using redux-persist. 我如何使用redux-persist只存储redux-state的一部分。 For example I have the following state 例如我有以下状态

const initialState = {
data: [],
fetched: false,
loadingUser: false
}

How can I store only the data without saving fetched and loadingUser boolean with redux-persist 我如何只存储数据而不保存已获取和加载的用户布尔值与redux-persist

You can use the whitelist and blacklist functionality, as outlined in the documentation. 您可以使用文档中概述白名单和黑名单功能。

//in your redux store config 
const persistConfig = {
  key: 'root',
  storage: storage,
  whitelist: ['data'] // only data will be persisted
};

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

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