'Scalable Solution to fetch Initial State from API for Functional Components

The documentation and examples I have found around loading initial state prescribe loading data in a lifecycle hook, for classes, or in a useEffect with an empty dependency array. I am having trouble finding a more scalable solution.

Is there a recommendation against checking for null or stale state values in the action and then asynchronously populating? This would leave children components to re-render when the state is updated with initial values, as a result of connect() or useSelector().

The goal being to prevent each component from managing the state and centralizing API call for a growing enterprise application.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source