0

I have the following middleware. enter image description here this middleware acts like the redux-thunk middleware, but passing the dispatcher and the state getter to the action creator function, but also I pass the next middleware that can be called. in this case I can export all my middlewares like this enter image description here

so In my action creator, instead of dispatching the action, I just pass it to the next middleware. enter image description here

I just want to know why I should use redux-thunk instead of this simple customThunk middleware?

user3550446
  • 405
  • 3
  • 10
  • 1
    What's the benefit of sending an action straight to the next middleware in the pipeline, instead of starting it at the beginning? Based on the middleware setup you show, all you're doing is giving the action to `checkMessageMiddleware` first, instead of `customThunk`, which seems pointless. – markerikson Sep 28 '17 at 22:41
  • I got it, the dispatch method call again the entire stack of middlewares before the action arrives to the reducers. thanx – user3550446 Sep 29 '17 at 09:09

0 Answers0