React multiple components rely on the same data, so how should the data be handled?

such as the title.

because two components are involved, I intend to use redux. The thing is, these two components are not displayed at first, in other words, the data does not need to be loaded by ajax at the beginning, and the data is not loaded until a component is triggered to load. If another subsequent component is also loaded, go directly from the redux.

the logic here is that if the redux has the data, it will be fetched directly, and if not, it will be loaded once from the server. It is not quite understood here, does each redux data have to be divided into three states: loading for the first time, loading, loading completion? It"s a little complicated! How do we deal with things like this?


it seems that the behavior of the two components in terms of data is equivalent, so you should determine the existence of the data in the didmount of the two components, and request if it does not exist.

if there is a possibility that the second component will be loaded before the first component request returns, then the request needs to be throttled.


since you don't need display at first, you just need to get the data when it's triggered and render.

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-1b2bed6-2bada.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-1b2bed6-2bada.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?