Here is my code for persistConfig
and store
, I want to add blacklist
for tracking
, but not for all tracking state, but only for tracking.checkingOut
, tracking.checkingIn
and tracking.searching
, how to do this correctly? I understand that if I want to remove tracking completely, I will need to write blacklist: ['tracking']
inside persistConfig
, but I'm not sure what to do in case of nested states.
const persistConfig = {
key: 'root',
storage: AsyncStorage,
}
const persistedReducer = persistReducer(persistConfig, reducers)
const createStoreWithMiddleware = applyMiddleware(thunkMiddleware)(createStore);
export const store = createStoreWithMiddleware(persistedReducer);
export const persistor = persistStore(store);
if I will add blacklist like this: blacklist: ['tracking.checkingOut', 'tracking.checkingIn', 'tracking.searching'] will it work? or there should be different approach for this?
You can use persistReducer
deeper in your reducer tree:
combineReducers({
location,
i18n,
tracking: persistReducer({ key: 'tracking', storage: AsyncStorage, blacklist: ['whateverYouWantTo'] }),
})
There is an example in the official docs of redux-persist
- https://github.com/rt2zz/redux-persist#nested-persists