//reducer
export const initialState = {
step: 1,
...other values
};
export default function myReducer(state = initialState, action) {
...
}
//reducers/index
const rootPersistConfig = {
key: 'root',
storage: storage,
blacklist: [],
};
const myReducerConfig = {
key: 'cp',
storage: storage,
blacklist: ['step',],
debug: true,
};
const rootReducer = combineReducers({
myReducer: persistReducer(myReducerConfig, myReducer),
});
export default persistReducer(rootPersistConfig, rootReducer);
//store.js
export const store = createStore(reducer, {}, composeWithDevTools(applyMiddleware(thunk)));
export const persistor = persistStore(store)
//debug returns
redux-persist/stateReconciler: rehydrated keys 'l_persist'
and all other values except 'step'
but 'step' still hydrate
if I set blacklist for root reducer and set name of reducer (myReducer) to it
full reducer is blacklisted as expected
but how to blacklist only property 'step' in myReducer
version: 5:10:0
I think this is the expected behavior, if you don't blacklist the nested reducer the rootReducer is expected to handle the persist configuration.
Please use markdown code snippets for better readability ;)
@TomPradat
updated question
I mean how to prevent persist to storage only one property of myReducer
example above still save to storage
Here is an example with only the property step blacklisted : https://codesandbox.io/s/8ylzw72658

@TomPradat
works, thanks
but if needed to blacklist further deep
like if
step: {
type: 'smt',
number: 0
}
and need to blacklist only 'number'
For this I think you should have a child reducer for your step object.
You can also look at https://github.com/rt2zz/redux-persist#transforms. I didn't try it but this might work for your use case
Most helpful comment
Here is an example with only the property step blacklisted : https://codesandbox.io/s/8ylzw72658