Answer the question
In order to leave comments, you need to log in
When to make asynchronous requests?
I’m writing in react and redux and just now I’m thinking why should I use middleware if you can just make an asynchronous request to componentDidMount and then dispatch it like a normal actioncreator ?
And you can call any other function and then how will it return the answer already dispatch the data?
why then use redux-thunk redux-saga
Answer the question
In order to leave comments, you need to log in
1. Because hooks in React appeared in version 16.8, and redux-thunk, redux-saga earlier and those who already use them will have to rewrite the working code.
2. The approaches themselves are still different. And if one approach works for you and works well, why would the other be better?
redux-thunk and redux-saga are designed to conveniently support transactions when, for example, it is necessary to process a chain of asynchronous requests, + this is all taken out in a separate layer of logic, allowing you to concentrate on it in one place, and on ui in another
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question