Skip to content

Commit

Permalink
fix(persistReducer): Ensure nested reducers can handle PERSIST too. F…
Browse files Browse the repository at this point in the history
…ixes #940 (#1048)
  • Loading branch information
jscinoz authored and rt2zz committed Jun 8, 2019
1 parent 2cd1eca commit 5ad36b8
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/persistReducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,15 @@ export default function persistReducer<State: Object, Action: Object>(
if (!_persistoid) _persistoid = createPersistoid(config)

// @NOTE PERSIST can be called multiple times, noop after the first
if (_persist) return state
if (_persist) {
// We still need to call the base reducer because there might be nested
// uses of persistReducer which need to be aware of the PERSIST action
return {
...baseReducer(restState, action),
_persist,
};
}

if (
typeof action.rehydrate !== 'function' ||
typeof action.register !== 'function'
Expand Down

0 comments on commit 5ad36b8

Please sign in to comment.