TypeError: middleware is not a function
According to the docs you are mixing up the usage of redux-logger
You either need to import the specific createLogger
function
import { createLogger } from 'redux-logger'
const logger = createLogger({
// ...options
});
Or use the default import
import logger from 'redux-logger'
And then your code should be fine
const store = createStore(
reducers,
applyMiddleware(thunkMiddleware, logger)
)
import logger from 'redux-logger';
import thunk from 'redux-thunk';
import reduxPromiseMiddleware from 'redux-promise-middleware';
import { applyMiddleware, createStore } from 'redux';
const middleware = applyMiddleware(reduxPromiseMiddleware, thunk, logger);
const store = createStore(reducer, middleware);
I was getting the same error TypeError: middleware is not a function.
import { createStore, combineReducers, applyMiddleware } from "redux";
import { createLogger } from "redux-logger";
import thunk from "redux-thunk";
import math from "./reducers/mathReducer";
import user from "./reducers/userReducer";
const logger = createLogger();
export default createStore(
combineReducers({ math, user }),
{},
applyMiddleware(logger, thunk)
);
Replacing applyMiddleware(logger, thunk)
with applyMiddleware(logger, thunk.default)
worked for me.