| ▲ | zarzavat 3 days ago | |
> You cannot load any data in a regular React application before you loaded both React and your React components that trigger the fetch. You totally can! Don't call fetch directly from a component - it's brittle. Write a hook to abstract that into one place. In your hook you can support prefetching by awaiting the promise you fired before you loaded your JS bundle (if you don't want to modify the server), or else take advantage of the browser cache. In this way your data and code can load in parallel. Is it common? Not really. But it's a technique that is in the toolbox of a conscientious webdev. | ||