Next.js Discord

Discord Forum

Best place to load data in RSC

Unanswered
Harlequin posted this in #help-forum
Open in Discord
HarlequinOP
With RSC, is it still better to load all the data from the DB in the pages.tsx file, then pass down the additional data to display via lists?
Or is it better to pass the DB loading to each component, eg the <ItemList> loads the data it displays, and the top level page just renders the list without needing to think about the data?

How does this work with an edit button that launches a modal/form to edit the item, should that data come from the page.tsx and pass through to the modal, or should the <EditItemModal> component fetch the item's data to display in a form and handle the saving etc to keep it all self-contained?

It could be a "it depends" type of answer, but it'd be good to know if either option is an antipattern/not ideal.

0 Replies