【问题标题】:How to store only a part of the redux state using redux-persist如何使用 redux-persist 仅存储部分 redux 状态
【发布时间】:2019-06-17 06:46:42
【问题描述】:

如何使用 redux-persist 仅存储部分 redux-state。例如我有以下状态

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

如何只存储数据而不使用 redux-persist 保存 fetched 和 loadingUser 布尔值

【问题讨论】:

    标签: reactjs redux redux-persist


    【解决方案1】:

    您可以使用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
    };
    

    【讨论】:

      猜你喜欢
      • 2021-08-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-09-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-01-19
      相关资源
      最近更新 更多