Search code examples
javascriptreduxreact-reduxmiddleware

In Redux, using middlewares to enhance store gives 'unexpected keys' error


I am getting this error:

Unexpected keys "dispatch", "subscribe", "getState", "replaceReducer", "liftedStore" found in preloadedState argument passed to createStore. Expected to find one of the known reducer keys instead: "form". Unexpected keys will be ignored.

My new redux store, with applied middleware is:

// redux extension
const composeEnhancer = window.__REDUX_DEVTOOLS_EXTENSION__ || compose;
const enhancer = composeEnhancer(applyMiddleware(promiseMiddleware()));
const store = createStore(reducer, enhancer);

I followed the guidelines from here: https://github.com/zalmoxisus/redux-devtools-extension


Solution

  • Replace __REDUX_DEVTOOLS_EXTENSION__ with __REDUX_DEVTOOLS_EXTENSION_COMPOSE__. The former is a complete enhancer that you can pass directly to createStore in case you're not using any middleware or enhancers. The latter is the composition function you're looking for.