Answer the question
In order to leave comments, you need to log in
Answer the question
In order to leave comments, you need to log in
Why not? can. But you must understand that as soon as the component is unmounted you will lose data. Therefore, requests are usually made in redux actions and the received data is stored in redux. Thus, as long as you have convenient access to the received data from different components + you do not need to re-request because you already have them in redux.
And middleware is just a layer between the dispatch and the moment when the data will be put into the redux. At this point, you can, for example, add some more logic. For example, check the server token for the fact that it has not yet expired, and if it has expired, throw it out for authorization or make a request for renewal.
For example: there is a conveyor along which the coat moves. Zina and Lyudmila work on the assembly line. Zina sews on a button, Lyudmila attaches a tag. Suddenly, the middleware Lena appears, stands between Zina and Lyudmila and paints the button in a hipster trendy color. Since Lena does not take the coat with her after painting, but passes it on, Lyudmila, as if nothing had happened, attaches a tag and the coat is ready. Only now it's hipster. Reinforced.Read here
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question