Should redux manage data as much as possible with redux?

as the title

if only component A will request apiA to get data, and the data will only be used by that component, then whether the data should be put into redux?

unrelated questions: if the request does not depend on the view content, should the request be sent as early as possible (such as in the constructor)

Mar.09,2021

in theory, it is stored only in the state used by the component itself. The state; within the component is stored in store if the component needs to be shared.

but in fact, it is written differently in many companies, and most of the companies I have come into contact with are placed on store, for easy maintenance when they expand in the future. My suggestion is to deal with it from a reasonable point of view in the light of the actual situation. Didn't say where it had to be.

"if the request does not depend on the view content, should the request be sent as early as possible"-Yes! But don't put it in the constructor, put it in componentDidMount, and since you don't depend on the view, let the view be displayed first and then call it. Why send it as early as possible?!

-this is the dividing line-

I just saw a similar problem in Zhihu, and I feel like that's what I want to say.
Reference: https://www.zhihu.com/questio.


when you are still blurred, use redux to manage it.
when you can tell what kind of data to use redux and what kind of data to use component state, you can do whatever you want.

Menu