From c4a8bf398736b3547580a594de2b4729f8691abd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eysenck=20G=C3=B3mez?= Date: Thu, 14 Apr 2016 13:27:55 -0500 Subject: [PATCH] Add support for enhancers in persistState Fix error when using enhancer like applyMiddleware as parameter in createPersistentStore --- src/persistState.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/persistState.js b/src/persistState.js index bb9e62e..dfb63bb 100644 --- a/src/persistState.js +++ b/src/persistState.js @@ -35,7 +35,12 @@ export default function persistState(paths, config) { deserialize } = cfg - return next => (reducer, initialState) => { + return next => (reducer, initialState, enhancer) => { + if (typeof initialState === 'function' && typeof enhancer === 'undefined') { + enhancer = initialState + initialState = undefined + } + let persistedState let finalInitialState @@ -46,7 +51,7 @@ export default function persistState(paths, config) { console.warn('Failed to retrieve initialize state from localStorage:', e) } - const store = next(reducer, finalInitialState) + const store = next(reducer, finalInitialState, enhancer) const slicerFn = slicer(paths) store.subscribe(function () {