Loading.tsx only shows briefly during long RSC data fetch #51203
Replies: 4 comments 2 replies
-
|
Since a default
In this case, you can use
import { Suspense } from 'react'
import { PostFeed, Weather } from './Components'
export default function Posts() {
return (
<section>
<Suspense fallback={<p>Loading feed...</p>}>
<PostFeed />
</Suspense>
<Suspense fallback={<p>Loading weather...</p>}>
<Weather />
</Suspense>
</section>
)
}Reference |
Beta Was this translation helpful? Give feedback.
-
|
Have you managed to solve this issue? |
Beta Was this translation helpful? Give feedback.
-
|
No I never figured out what to do to solve the issue and haven't had time to go back to it. I ended up doing most of the work in client components... |
Beta Was this translation helpful? Give feedback.
-
|
I have precisely the same issue as @Yonisegev described. Interestingly, I can not reproduce it on the local machine. I've tried to use production mode and simulate the extended API response - but it didn't help to reproduce. But I can reproduce it quite easily on Vercel. Especially if my BE on AWS Lambda is not warmed up. Here is an example of how the loading state disappears, and there is a white screen for a few moments until the data arrives: Screen.Recording.2024-08-10.at.00.09.54.movDoes anyone know how to fix that? |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I'm having an issue where navigating to a app dir page seems to send two requests to the server.
As an RSC, when navigating to the page, it fetches data from the server that can take some time. During that fetch time, I expect the loading.tsx to display. However, when the two requests are sent, the loading.tsx is displayed for a split second, then the page is displayed (without the data we're waiting for) and, finally, when looking at the network requests, I can see the first request finish.
In the example video, on the final page (Step 5/Article) you can see the two network requests, the blank page which appears after a moment and the time updating for the first request (after the server has finished the long fetch).
https://www.youtube.com/watch?v=2nhfllPsSUE
Beta Was this translation helpful? Give feedback.
All reactions