Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Readme update - nested configs alternative #1391

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down