-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Keep prerender component tree the same as regular render tree #7760
Conversation
16 replays were recorded for 37d7acb. 16 PassedrequireAuth graphql checks
|
…e-prerender-react18
…dwood into tobbe-prerender-react18
4d0eff9
to
52b6166
Compare
- update babel plugin to add webpack chunk name - remove server markup - revert hydrate logic - insert chunk in prerendered html file
Next steps: make sure tests still account for #4948 while refactoring. |
return NamedCell | ||
return (props: CellProps) => { | ||
return ( | ||
<Suspense fallback={<div>Loading suspense...</div>}> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🙌🏻
Do we want to allow for a custom fallback
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I need to do some more investigations and experiments, but my initial impression is that the fallback isn't used by React in the very specific circumstances we're using it here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there is value in custom fallback
s.
Looking at the <Suspence>
docs, there are examples with varying degrees of specificity ( e.g. BigSpinner
vs AlbumsGlimmer
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 to custom fallbacks. But I think Tobbe is correct that the fallback actually be used for this specific case.
If we're incorrect, we can add/improve in follow on.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When we switch/upgrade to renderToPipeableStream
we'll have to revisit this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From the new React docs https://react.dev/reference/react/Suspense#displaying-a-fallback-while-content-is-loading (scroll down to Note)
Only Suspense-enabled data sources will activate the Suspense component. They include:
Apollo Client is not yet Suspense-enabled, so rendering cells will not cause <Suspense>
to suspend, and therefore the fallback will never be rendered.
Suspense (and SSR) support in Apollo is tracked here: apollographql/apollo-client#10231
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI we've got suspense support in our latest 3.8.0-alpha.x releases, so you can test it out in a beta/alpha here if it helps. Let us know how we (the Apollo Client team) can support you!
Just as a status:
We've got some changes that will make useSuspenseQuery
work with useDeferredValue
and startTransition
. We will be exploring how to get streaming cache updates working in SSR coming up next, so I'm hopeful that once you've got renderToPipeableStream
working, you'll be able to hook it up to the primitive we export from the library to get it working.
Hope that helps!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great to hear @jerelmiller! This PR isn't blocked. But other priority work in progress will need Apollo Client support. We'll loop back as needed. Thanks.
…dwood into tobbe-prerender-react18
React 18's tree diffing works differently compared to React 17.
This PR changes the logic so that we use the same code for both pre-render and regular rendering to a much greater extent.
Fixes #7757