Skip to content

Commit dc0bfba

Browse files
committed
fix(persistReducer): Ensure nested reducers can handle PERSIST too. Fixes rt2zz#940
1 parent 2cd1eca commit dc0bfba

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/persistReducer.js

+9-1
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,15 @@ export default function persistReducer<State: Object, Action: Object>(
106106
if (!_persistoid) _persistoid = createPersistoid(config)
107107

108108
// @NOTE PERSIST can be called multiple times, noop after the first
109-
if (_persist) return state
109+
if (_persist) {
110+
// We still need to call the base reducer because there might be nested
111+
// uses of persistReducer which need to be aware of the PERSIST action
112+
return {
113+
...baseReducer(restState, action),
114+
_persist,
115+
};
116+
}
117+
110118
if (
111119
typeof action.rehydrate !== 'function' ||
112120
typeof action.register !== 'function'

0 commit comments

Comments
 (0)