This is a good question.
There is more than one answer to it. It depends on the setup at hand.
React provides the suspense
-function. It allows you to handle asynchronous component loading.
If you use a GraphQL interface to your database, you can use Apollo. This is a library with some components (e.g. <Query/>
) that provide asynchronous loading out of the box.
Finally, React supports plain JavaScript. So, you always have the option to fall back to it. Thus, you can use async/await and promises at various places.
This is just a brief overview. I think this is worth spending a whole post on it. (But that’s taking a little bit more time)