{"record":{"id":"16e1c7ba74ee8bfc","repo":"reduxjs/redux","slug":"expected-the-enhancer-to-be-a-function-instead-r","errorCode":null,"errorMessage":"Expected the enhancer to be a function. Instead, received: '${kindOf(enhancer)}'","messagePattern":"Expected the enhancer to be a function\\. Instead, received: '(.+?)'","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/createStore.ts","lineNumber":123,"sourceCode":"  if (\n    (typeof preloadedState === 'function' && typeof enhancer === 'function') ||\n    (typeof enhancer === 'function' && typeof arguments[3] === 'function')\n  ) {\n    throw new Error(\n      'It looks like you are passing several store enhancers to ' +\n        'createStore(). This is not supported. Instead, compose them ' +\n        'together to a single function. See https://redux.js.org/tutorials/fundamentals/part-4-store#creating-a-store-with-enhancers for an example.'\n    )\n  }\n\n  if (typeof preloadedState === 'function' && typeof enhancer === 'undefined') {\n    enhancer = preloadedState as StoreEnhancer<Ext, StateExt>\n    preloadedState = undefined\n  }\n\n  if (typeof enhancer !== 'undefined') {\n    if (typeof enhancer !== 'function') {\n      throw new Error(\n        `Expected the enhancer to be a function. Instead, received: '${kindOf(\n          enhancer\n        )}'`\n      )\n    }\n\n    return enhancer(createStore)(\n      reducer,\n      preloadedState as PreloadedState | undefined\n    )\n  }\n\n  let currentReducer = reducer\n  let currentState: S | PreloadedState | undefined = preloadedState as\n    | PreloadedState\n    | undefined\n  let currentListeners: Map<number, ListenerCallback> | null = new Map()\n  let nextListeners = currentListeners","sourceCodeStart":105,"sourceCodeEnd":141,"githubUrl":"https://github.com/reduxjs/redux/blob/3084fc33bb23ab4cab4796172eafe342da4e73d9/src/createStore.ts#L105-L141","documentation":"When createStore receives a third argument (or second, after the preloadedState-shift), it treats it as a store enhancer and must be callable. If the value is non-function (e.g. an object, string, or a devtools config), Redux cannot apply it because enhancers are functions of (createStore) => (reducer, preloadedState) => store.","triggerScenarios":"Passing window.__REDUX_DEVTOOLS_EXTENSION__() result incorrectly (calling compose on the extension object instead of the function); passing a configuration object where an enhancer function is expected; createStore(reducer, undefined, { trace: true }); typing-induced passing of a wrapped enhancer.","commonSituations":"Confusing redux-devtools-extension composeEnhancers with the raw devtools object; passing a preloaded-state object that is not detected as a function enhancer but then a third arg that is an object; migration where an enhancer was wrapped in an extra layer that returns an object.","solutions":["Ensure the enhancer argument is the function returned by applyMiddleware(...) or compose(...), not the result of calling a devtools factory incorrectly.","Use `window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose` to build a single function enhancer.","Log `typeof enhancer` before createStore to confirm it is 'function'.","Remove any stray third argument that was meant to be preloadedState (it was shifted incorrectly)."],"exampleFix":"// before\nconst store = createStore(\n  rootReducer,\n  applyMiddleware(thunk),            // preloadedState slot, gets shifted to enhancer OK\n  window.__REDUX_DEVTOOLS_EXTENSION__ // an object, not a function -> throws\n)\n\n// after\nconst composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose\nconst store = createStore(\n  rootReducer,\n  composeEnhancers(applyMiddleware(thunk))\n)","handlingStrategy":"type-guard","validationCode":"if (enhancer !== undefined && typeof enhancer !== 'function') {\n  throw new TypeError(`enhancer must be a function, got ${typeof enhancer}`)\n}\nconst store = createStore(reducer, preloadedState, enhancer)","typeGuard":"const isStoreEnhancer = (x): x is Function => typeof x === 'function'","tryCatchPattern":null,"preventionTips":["Confirm the enhancer is a function before passing it (log typeof).","Use redux-devtools-extension's composeEnhancers, not the raw extension object.","Don't put a config object in the enhancer slot."],"tags":["redux","createstore","enhancer","type-validation","devtools"],"backgroundTag":null,"analyzedSha":"3084fc33bb23ab4cab4796172eafe342da4e73d9","analyzedAt":"2026-08-12T13:21:41.727Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}