3 ms·
Surprised that redux-thunk is still alive in 2018, the cause of much of the most complicated and "ugly" code in Redux. Time to move to custom middleware(s)
by Murkin 8y ago
Surprised that redux-thunk is still alive in 2018, the cause of much of the most complicated and "ugly" code in Redux.
Time to move to custom middleware(s)
- fineng123 8y agoYou can use saga if it feeds your ego, sure. Redux is a simple tool and thunk is a simple library, and they both do their job.
- acemarke 8y agoWhy do you say that thunks are "the cause of complicated and ugly code" ? I'm a Redux maintainer, and I recommend thunks as the default choice for async logic. Most people just need to make some AJAX calls and dispatch an action when it returns, or maybe grab a value from the store state and work with it. Thunks are perfect for that kind of use case - complex synchronous logic, and simple async. In fact, with `async/await` syntax, I would be a bit more comfortable doing somewhat more complicated async logic in a thunk as well. I wrote a post a while back discussing some common objections to using thunks (and sagas), and why I feel thunks and sagas are still good choices for handling logic in Redux apps: https://blog.isquaredsoftware.com/2017/01/idiomatic-redux-thoughts-on-thunks-sagas-abstraction-and-reusability/ https://blog.isquaredsoftware.com/2017/01/idiomatic-redux-th... That said, yes, you should always feel free to write custom middleware to solve your own use cases.