我继承了一个使用redux-persist并且有多个reducer的项目。我为一个小功能写了一个新的减速器,坚持认为减速器会引起问题。它应该表现得没有redux-persist。
如何从持久化中省略一个reducer?或者,如果我不能,我该如何手动清除它?在文档中,https://github.com/rt2zz/redux-persist,我发现了这个:
persistor object
the persistor object is returned by persistStore with the following methods:
.purge(keys)
keys array An array of keys to be purged from storage. If not provided all keys will be purged.
...
所以,这可能是我需要的,但我不知道在哪里以及如何使用它。
答案 0 :(得分:4)
您可以使用blacklist
参数向react-persist
提供不应存储的Reducer列表。因此,如果do-not-store
是您不希望存储的reducer的关键,请使用:
const persistConfig = {
blacklist: ['do-not-store'],
...
}
persistStore(store, persistConfig)