Okay so ive been having a hard time understanding middleware and the applyMiddleware in redux and routerMiddleware in react-router-redux. Can some one explain to me what exactly it is in simple terms. Thank you.
It's just a simple layer, which can transform / validate / logg data after dispatch(someAction(data))
but before handling this action.
Common usages for middlewares is:
redux-thunk
- middleware for handling async actionsredux-logger
- Logging middleware for each action dispatchYou can imagine some other use cases, if you need to do something after each dispatch. For example you can store copies of your current store/state, to be able to revert data in future.