Skip to content

Commit

Permalink
change reducer is not a function err
Browse files Browse the repository at this point in the history
  • Loading branch information
Ahmed-Hakeem committed Dec 14, 2022
1 parent a075431 commit 75f37f9
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions src/createStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,15 @@ export default function createStore<
preloadedState?: PreloadedState<S> | StoreEnhancer<Ext, StateExt>,
enhancer?: StoreEnhancer<Ext, StateExt>
): Store<ExtendState<S, StateExt>, A, StateExt, Ext> & Ext {

if (typeof reducer !== 'function') {
throw new Error(
`Expected the root reducer to be a function. Instead, received: '${kindOf(
reducer
)}'`
)
}

if (
(typeof preloadedState === 'function' && typeof enhancer === 'function') ||
(typeof enhancer === 'function' && typeof arguments[3] === 'function')
Expand Down Expand Up @@ -99,14 +108,6 @@ export default function createStore<
) as Store<ExtendState<S, StateExt>, A, StateExt, Ext> & Ext
}

if (typeof reducer !== 'function') {
throw new Error(
`Expected the root reducer to be a function. Instead, received: '${kindOf(
reducer
)}'`
)
}

let currentReducer = reducer
let currentState = preloadedState as S
let currentListeners: (() => void)[] | null = []
Expand Down

0 comments on commit 75f37f9

Please # to comment.