Hey everyone, I'm still getting the hang of using the app router and I've come across something that puzzles me. Suppose I'm retrieving data in a page.tsx
file and passing it as props to a component that requires this data. To manage the loading state, I'd typically wrap the component within a <Suspense/>
tag. However, it appears <Suspense/>
doesn't recognize that the nested component is waiting for data since the data fetching occurs at a higher level in the component tree. Is that correct?
It seems like the solution is to move data fetching inside the component itself. However, if I need to render something that specifically requires client-side execution, it would necessitate invoking yet another component. Here's an example to illustrate my point:
In this setup, <Suspense/>
isn't aware that INeedSomeData
is awaiting the fetched data. So, I'm thinking the better approach is to have the component fetch its data, like this:
This works, but this makes it necessary for another nested component. Am I getting this pattern wrong? I'd love some opinions, thanks!