Skip to content

Commit c4a8bf3

Browse files
author
Eysenck Gómez
committed
Add support for enhancers in persistState
Fix error when using enhancer like applyMiddleware as parameter in createPersistentStore
1 parent d0cb14c commit c4a8bf3

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/persistState.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,12 @@ export default function persistState(paths, config) {
3535
deserialize
3636
} = cfg
3737

38-
return next => (reducer, initialState) => {
38+
return next => (reducer, initialState, enhancer) => {
39+
if (typeof initialState === 'function' && typeof enhancer === 'undefined') {
40+
enhancer = initialState
41+
initialState = undefined
42+
}
43+
3944
let persistedState
4045
let finalInitialState
4146

@@ -46,7 +51,7 @@ export default function persistState(paths, config) {
4651
console.warn('Failed to retrieve initialize state from localStorage:', e)
4752
}
4853

49-
const store = next(reducer, finalInitialState)
54+
const store = next(reducer, finalInitialState, enhancer)
5055
const slicerFn = slicer(paths)
5156

5257
store.subscribe(function () {

0 commit comments

Comments
 (0)