securecurve securecurve - 4 months ago 14
Javascript Question

Redux's applyMiddleware cannot render middlewares

I'm trying to use middleware in the following code

import { thunk } from 'redux-thunk'
import {logger} from 'redux-logger'
import { createStore, applyMiddleware, compose } from 'redux'

export const store = createStore(rootReducer , defaultState , applyMiddleware(thunk,logger) )


But I keep getting this error in the browser no matter what the middleware I use is:

enter image description here
And the page stops rendering!!

and it only works when I remove all the middleware from applyMiddleware, like this:

export const store = createStore(rootReducer , defaultState , applyMiddleware() )


P.S. I'm using the following libraries versions:

"react": "^15.2.1",
"react-dom": "^15.2.1",
"react-redux": "^4.4.1",
"redux": "^3.5.2",
"redux-thunk": "^2.1.0"


What can the problem be?

Answer

Updated, based on your comment below. Try:

import thunk from 'redux-thunk';
import createLogger from 'redux-logger';

const logger = createLogger();

createStore(rootReducer , defaultState , applyMiddleware(thunk,logger)

It's highly recommended that you refer to the documentation for the libraries you are using.

Comments