Skip to content

Nested configs are no longer necessary #1371

@PiotrKujawa

Description

@PiotrKujawa

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.

@rt2zz @ckalika please take a look. Thanks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions