Description
I'm starting to see this demo being used in performance comparisons in a way that implies this is the canonical RSC experience. It would be good to either solve or document (in README) concrete issues with it so that a future reader has an idea of what's correct and what's a known issue. (I've added reactjs/server-components-demo#57 to the original demo in the same spirit.)
Update
The up-to-date list of problems (likely non-exhaustive) is here: #13 (comment)
Streaming "Jank"
This demo shows each story "streaming in" individually:
bad_ux.mov
This is a rather janky user experience.
I am guessing that this demo does it to make the "streaming" aspect obvious. However, I am observing that people take away that this jankiness is what we mean by "streaming". It seems like a rather unfortunate consequence if people's takeaway becomes that apps built with Server Components have pieces randomly "popping in" — especially because the whole point of the <Suspense>
model is to give you precise control over what's allowed to "pop in" individually vs what pieces must "pop in" together.
How to fix it?
If I understand correctly, there are multiple ways to fix this:
-
Remove this
<Suspense>
boundary so that all stories "pop in" at once. Despite delaying the display, this is a much better user experience because there's no content layout shift, and individual jumping rows aren't useful anyway.- I think you'll also want to replace the "top-level" spinner with null and make the body full-height so that the loading sequence before we get the stories isn't jumpy either. Ideally we'd either hold the entire page or show the shell that will be "filled in" — both of these could feel natural. A small body with a spinner in the top left corner looks weird.
- I've tried doing that, but ran into a hydration error I couldn't fix. Is that a bug in React? For some reason, the exact place where the error happens wasn't reported in the console so I've had a hard time trying to fix this. It seems like there needs to be an investigation for:
- Why removing this
<Suspense>
boundary breaks hydration - Why errors are not being fully reported to the console
- Why removing this
-
Alternatively, use
<SuspenseList>
, replace a spinner fallback with null, and hide the tail, so that you only see stories appearing "in order". This is currently out of question because<SuspenseList>
won't be in 18.0 and will come later in 18.x. It's not currently implemented on the server.
Additional server request
I am seeing an extra request to the RSC entry point from the client after the page loads:
I wouldn't expect the initial page load to need to make any additional requests. Do we understand why it happens? Is this a bug or a known limitation of the current demo?
Thanks
I very much appreciate the work on this demo. I'm hoping we can fix and/or document the issues in it so that people are aware what's missing and don't make an impression of the overall RSC architecture or user experience based on an early demo.
Thanks!