From 4c51e7a5f303b88f44cd463dab00e4f63e0011fa Mon Sep 17 00:00:00 2001 From: Piotr Kujawa Date: Wed, 22 Jun 2022 17:28:51 +0200 Subject: [PATCH] Readme update - nested configs alternative --- README.md | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/README.md b/README.md index 9a963053..3fea9b15 100644 --- a/README.md +++ b/README.md @@ -228,6 +228,28 @@ const rootReducer = combineReducers({ export default persistReducer(rootPersistConfig, rootReducer) ``` +## Nested Persists - Config Alternative +Since 25th March 2022, it is possible to use an alternative way of setting nested persist configuration. +There is a new package called [Redux Deep Persist](https://github.com/PiotrKujawa/redux-deep-persist) and there is a helper method _getPersistConfig_ to get a redux persist config for nested state no matter how deep you want it to be persisted. + +**Example of usage:** + +```js +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 +}) +``` + ## Migrations `persistReducer` has a general purpose "migrate" config which will be called after getting stored state but before actually reconciling with the reducer. It can be any function which takes state as an argument and returns a promise to return a new state object.