3 ms·
One of the touted benefits of RSCs is actually colocation of code while avoiding waterfalls. Naively, you can implement a component that fetches some data (eg
by doytch 3y ago
One of the touted benefits of RSCs is actually colocation of code while avoiding waterfalls.
Naively, you can implement a component that fetches some data (eg, post) and renders. Some descendants may also need to fetch data and render it. But now you’re blocking the descendants from rendering until the first fetch completes, so you have a waterfall load that takes unnecessarily long.
An alternative has always been to fetch everything at the route/top level. But now it starts to feel a bit strange that your route component needs to know about everything its descendants need.
RSCs promise to allow you implement the former pattern which gives better maintainability without the performance hit of a waterfall since the entire render-fetch-data-render back and forth is done on the backend near your data.
- squidsoup 3y agoThis is a problem nicely solved by graphql fragments - components declare their data dependencies, and the compiler generates a single query.