A problem with data refresh by useAsyncData()
Closed this issue · 1 comments
Here is the deal: if the component using the hook is re-rendered for a reason unrelated to this hook after the data maxage has passed, the data refresh won't be triggered automatically, as the refresh is protected by useEffect(..)
. I believe, it needs to be handled as a special case: if there are previously loaded data, but they are stale according to maxage
, the re-loading should be attempted, assuming it is permitted by refreshAge
.
react-global-state/src/useAsyncData.js
Lines 120 to 132 in d2d97a9
On the other hand, it was more like a deliberate design decision: if something leads to the component update, that should be mentioned as dependency, and then it will work. Need an extra thought about it. Probably, introduce different component modes, which do this with different logic?