From 5ad36b8739b986a3cc2f8733db525996af937fe7 Mon Sep 17 00:00:00 2001 From: Jack Coulter Date: Sun, 9 Jun 2019 08:15:00 +1000 Subject: [PATCH] fix(persistReducer): Ensure nested reducers can handle `PERSIST` too. Fixes #940 (#1048) --- src/persistReducer.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/persistReducer.js b/src/persistReducer.js index 6eecfe8f1..cf8d980f7 100644 --- a/src/persistReducer.js +++ b/src/persistReducer.js @@ -106,7 +106,15 @@ export default function persistReducer( 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'