How does the sub-data in redux state load data asynchronously for the first time?

look at the title, I guess you don"t understand, ha, I don"t understand either?

Let me describe it in detail

this is the case. I intend to store a data in redux. This data will be used in some sub-component of the application. The default value needs to be loaded from the server-side api. The key point is that this sub-component is hidden by default.

so. My understanding is:

Application loading does not need to load this data, and when this subcomponent is displayed, the data is loaded asynchronously. So, the problem is, after loading, the subcomponent is unloaded again, and then it is displayed again, so there is no need to load the data asynchronously again, but how do I know that this is not the first time it has been loaded? Do you judge according to the data of state? no, it violates the principle of ui=f (data).


1. First, loading data can be handled in the didmounted lifecycle hook function
2. It is not necessary to re-request data from the backend api when you have data to mount again, because the data may have changed during your component unloading, or since you last loaded it, so you need to reload the latest data each time the component is mounted
3. It is necessary to request a second request, because the data may have changed during your component unloading, or since the last time you loaded it, it is necessary for the component to reload the latest data each time it is mounted. Even if you make a judgment, it does not violate the principle of ui=f (data) . You can understand that the data here is mapped to the data, needed by ui, and these data may come directly from state, or they may be processed by a layer


. Can you store a logo in state to determine whether the data should be loaded

?
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1ea2102-4f077.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1ea2102-4f077.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?