Redux-persist 如何持久化一些状态

Redux-persist how to persist some state

我已经使用 redux-persist 一段时间了,它确实是一个很棒的工具,但问题是它只是持久化我所有的状态(reducer),我想知道有没有办法选择要保留的状态。 谢谢

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

例如:

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

Official documentation