redux-persist
redux-persist copied to clipboard
How to persist a part of the store?
Hi, Now I use Whitelist to persist just a part of the store like:
const persistConfig = { key: 'root', storage, whitelist: ['ui', 'communication'] };
but I need to persist just a part of UI, for example it could be like
const persistConfig = { key: 'root', storage, whitelist: ['ui.panels', 'ui.paddings', 'communication.list'] };
Is it any way to do this?
set up several configs, each on a different key, see https://github.com/rt2zz/redux-persist#nested-persists
Probably close this?!
Here is what you can do using my package redux-deep-persist, which can be helpful in creating a redux-persist config.
import { getPersistConfig } from 'redux-deep-persist';
const config = getPersistConfig({
key: 'root',
storage: LocalStorage, // whatever storage you use
whitelist: [
'a1.b1.c1',
'a2.b2.c2',
'a3',
'a4.b4.c4.no.matter.how.deep.you.go'
],
rootReducer, // your root reducer must be also passed here
... // any other props from original redux-persist config, omitting the stateReconciler
});