Skip to content

Commit 75f37f9

Browse files
committed
change reducer is not a function err
1 parent a075431 commit 75f37f9

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

src/createStore.ts

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,15 @@ export default function createStore<
6868
preloadedState?: PreloadedState<S> | StoreEnhancer<Ext, StateExt>,
6969
enhancer?: StoreEnhancer<Ext, StateExt>
7070
): Store<ExtendState<S, StateExt>, A, StateExt, Ext> & Ext {
71+
72+
if (typeof reducer !== 'function') {
73+
throw new Error(
74+
`Expected the root reducer to be a function. Instead, received: '${kindOf(
75+
reducer
76+
)}'`
77+
)
78+
}
79+
7180
if (
7281
(typeof preloadedState === 'function' && typeof enhancer === 'function') ||
7382
(typeof enhancer === 'function' && typeof arguments[3] === 'function')
@@ -99,14 +108,6 @@ export default function createStore<
99108
) as Store<ExtendState<S, StateExt>, A, StateExt, Ext> & Ext
100109
}
101110

102-
if (typeof reducer !== 'function') {
103-
throw new Error(
104-
`Expected the root reducer to be a function. Instead, received: '${kindOf(
105-
reducer
106-
)}'`
107-
)
108-
}
109-
110111
let currentReducer = reducer
111112
let currentState = preloadedState as S
112113
let currentListeners: (() => void)[] | null = []

0 commit comments

Comments
 (0)