【问题标题】:Redux-persist how to persist some stateRedux-persist 如何持久化一些状态
【发布时间】:2018-09-14 21:20:06
【问题描述】:

我一直在使用 redux-persist 一段时间的每个人,这确实是一个很棒的工具,但问题是它只会保留我所有的状态(减速器),我想知道有没有办法选择哪个状态是持久的。 谢谢

【问题讨论】:

  • 查看“白名单”配置选项

标签: reactjs react-redux redux-persist


【解决方案1】:

在您的 redux-persist 配置中,您可以根据需要添加 whitelistblacklist。它们采用您想要包括(白名单)或忽略(黑名单)的状态数组。

例如:

const persistConfig = {
  key: 'root',
  blacklist: ['state-not-to-be-persisted']
}

Official documentation

【讨论】:

    猜你喜欢
    • 2018-08-14
    • 2022-11-11
    • 2017-10-08
    • 2019-04-14
    • 2022-12-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-12-25
    相关资源
    最近更新 更多