redux-persist: Problem with PersistStore whitelist

Hi, I was trying to make only one reducer persist like in my code below:

persistStore(store, {whitelist: ['login']});

But all my reducers keep persisting,how I am suppose to make the whitelist to work? Thank you in advance!

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 1
  • Comments: 22 (3 by maintainers)

Most upvoted comments

2019, and still got this issue… too

2019, and still got this issue… any solutions here?

I am also having this issue:

const channelPersistConfig = {
  key: 'channel',
  storage,
  stateReconciler: autoMergeLevel1,
  blacklist: ['messages']
}

const metaPersistConfig = {
  key: 'meta',
  storage,
  stateReconciler: autoMergeLevel1,
  whitelist: ['channel']
}

const channelReducer = persistCombineReducers(channelPersistConfig, {
  messages: messagesReducer,
  meta: persistReducer(metaPersistConfig, metaReducer)})

export default channelReducer;

is my reducer, combined into my rootReducer using

const rootPersistConfig = {
  key: 'root',
  storage,
  stateReconciler: autoMergeLevel1
};

const reducers = {
  auth,
  nav: navReducer,
  channel: channelReducer
};
const rootReducer = persistCombineReducers(rootPersistConfig, reducers);

Despite the white/black list nested configs, the entire state is persisted from all reducers, as I can see by inspecting action.payload in my ‘persist/REHYDRATE’ state listener.

Am I using this correctly?

maybe 2021 still got this issue… too

@dchersey , I am trying to do something similar with having a combination of whitelist and blacklist to cherry pick what I want to persist in redux. Have you managed to solve this? Any leads for me (and anyone who land up here).

I’m following the docs in the Migration guide that say to

replace combineReducers with persistCombineReducers
e.g. let reducer = persistCombineReducers(config, reducers)

This is inconsistent with the info in the README under nested persists … but it seemed pretty clear and I thought it would supercede it. But that is confusing … maybe it should go back to combineReducers?

Zack, thank you very much for your help! persistStore(store, { storage: AsyncStorage, whitelist: [‘something’] });

Errors:

  1. redux-persist: invalid option passed to persistStore: “whitelist”. You may be incorrectly passing persistConfig into persistStore, whereas it should be passed into persistReducer.

  2. redux-persist: invalid option passed to persistStore: “storage”. You may be incorrectly passing persistConfig into persistStore, whereas it should be passed into persistReducer.

  • node_modules/redux-persist/lib/persistStore.js:50:38 in <unknown>
  • node_modules/redux-persist/lib/persistStore.js:49:23 in persistStore

@rt2zz - Sorry, it’s my bad! I’ve just fixed it. I haven’t noticed that combineReducers was replaced with persistCombineReducers.