-
Notifications
You must be signed in to change notification settings - Fork 860
Description
Hi everyone,
I'd like to introduce a new possibility in creating Redux Persist config using my package called Redux Deep Persist.
Nested configs are no longer necessary because you can use getPersistConfig method and define a nested whitelist or a blacklist using dot notation: whitelist: ['key1.nestedProp1.nestedProp2.nestedProp3', ...'] or blacklist: ['key1.nestedProp1.nestedProp2.nestedProp3', ...'].
Here's an example of configuration:
import { getPersistConfig } from 'redux-deep-persist';
const config = getPersistConfig({
key: 'root',
storage: AsyncStorage, // whatever storage you use
whitelist: [
'property1.a1.b1',
'property1.a2.b2.c2', // no matter how deep you go
'property2.a2',
],
rootReducer, // your root reducer must be also passed here
... // any other props from original redux-persist config omitting the stateReconciler
})My proposal is to add that note to the official documentation of Redux Persist as an alternative method of configuration.
I've seen lots of questions about "how to persist nested state", and because I had the same requirement in my own project I decided to make our life easier. Please let me know what do you think. I hope this will be helpful.