reduxjs/redux · error · Error
It looks like you are passing several store enhancers to cre
Error message
It looks like you are passing several store enhancers to createStore(). This is not supported. Instead, compose them together to a single function. See https://redux.js.org/tutorials/fundamentals/part-4-store#creating-a-store-with-enhancers for an example.
What it means
createStore accepts at most one enhancer. Redux detects when a caller passes two enhancers (either as the second and third positional args, or third and fourth) — this pattern means the enhancers were not composed, so only one would take effect and the other silently dropped. The error points to compose() as the supported way to combine enhancers.
Source
Thrown at src/createStore.ts:109
PreloadedState = S
>(
reducer: Reducer<S, A, PreloadedState>,
preloadedState?: PreloadedState | StoreEnhancer<Ext, StateExt> | undefined,
enhancer?: StoreEnhancer<Ext, StateExt>
): Store<S, A, UnknownIfNonSpecific<StateExt>> & NoInfer<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')
) {
throw new Error(
'It looks like you are passing several store enhancers to ' +
'createStore(). This is not supported. Instead, compose them ' +
'together to a single function. See https://redux.js.org/tutorials/fundamentals/part-4-store#creating-a-store-with-enhancers for an example.'
)
}
if (typeof preloadedState === 'function' && typeof enhancer === 'undefined') {
enhancer = preloadedState as StoreEnhancer<Ext, StateExt>
preloadedState = undefined
}
if (typeof enhancer !== 'undefined') {
if (typeof enhancer !== 'function') {
throw new Error(
`Expected the enhancer to be a function. Instead, received: '${kindOf(
enhancer
)}'`
)View on GitHub (pinned to 3084fc33bb)
Solutions
- Compose the enhancers into one: `createStore(reducer, preloadedState, compose(applyMiddleware(...), devToolsEnhancer()))`.
- With redux-devtools-extension use the preloadedState-aware form: `composeEnhancers(applyMiddleware(...))` as the single third argument.
- Confirm you are not accidentally spreading an array of enhancers as separate positional args.
Example fix
// before
const store = createStore(
rootReducer,
preloadedState,
applyMiddleware(thunk),
window.__REDUX_DEVTOOLS_EXTENSION__?.()
)
// after
import { compose, createStore, applyMiddleware } from 'redux'
const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose
const store = createStore(
rootReducer,
preloadedState,
composeEnhancers(applyMiddleware(thunk))
) Defensive patterns
Strategy: validation
Validate before calling
// Enforce a single composed enhancer before createStore:
const ensureSingleEnhancer = (...enhancers) => {
const fns = enhancers.filter(e => typeof e === 'function')
if (fns.length > 1) {
throw new Error('Pass a single composed enhancer via compose(...).')
}
return fns[0]
} Type guard
const isEnhancer = (x): x is Function => typeof x === 'function'
Prevention
- Always compose multiple enhancers into one with compose().
- Build devtools-aware compose via `window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose`.
- Pass enhancers as the single third argument to createStore.
When it happens
Trigger: createStore(reducer, preloadedState, applyMiddleware(...), devToolsEnhancer()) — two enhancers in positions 3 and 4; createStore(reducer, enhancerA, enhancerB) where the preloadedState slot was skipped and both enhancers land in slots 2 and 3; calling createStore with a variable-arg spread of enhancers.
Common situations: Adding redux-devtools enhancer alongside applyMiddleware without composing them; tutorial code that passes each enhancer separately; refactor that moved preloadedState into a different call site leaving two enhancers adjacent.
Related errors
- Expected the enhancer to be a function. Instead, received: '
- Expected the root reducer to be a function. Instead, receive
- You may not call store.getState() while the reducer is execu
- Expected the listener to be a function. Instead, received: '
- You may not call store.subscribe() while the reducer is exec
AI-assisted analysis of reduxjs/redux@3084fc33bb (2026-08-12).
Data as JSON: /api/errors/e986b442b8882ca3.
Report an issue: GitHub.