
Conditionally Apply Redux Middleware
There may be situations when you only want to apply certain redux middlewares. For example, I typically use redux-thunk
and redux-logger
but I don’t necessarily want to include the logger in my production build. One way to accomplish this is to add any middleware you want to use into an array, which allows you to apply your conditional logic to determine what should be added, and then use the spread operator (…) to apply that middleware.