developerasun / myCodeBox-web

Open source code box for web developers.
Apache License 2.0
5 stars 0 forks source link

React/Redux : apply multiple middlewares #158

Closed developerasun closed 2 years ago

developerasun commented 2 years ago

research : how to apply multiple middlewares to Redux

read this

developerasun commented 2 years ago

solution : use array and spread operator like below.

import { createStore, applyMiddleware } from 'redux'
import { rootReducer } from './rootReducer'
import logger from 'redux-logger'
import thunk from 'redux-thunk'

const middlewares = [logger, thunk]
const store = createStore(rootReducer, applyMiddleware(...middlewares))

export default store