-
-
Couldn't load subscription status.
- Fork 3.5k
Update HydrationStreamProvider.tsx + Advanced SSR docs to fix unnecessary suspensions #6753
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
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
6d395fa
Update HydrationStreamProvider + advanced SSR docs
mgreenw 0ba6af4
Implement PR feedback
mgreenw 6a1c1b3
Merge remote-tracking branch 'upstream/main' into nextjs-suspense-fixes
mgreenw 32f2038
Merge branch 'main' into nextjs-suspense-fixes
mgreenw f308d7e
Merge branch 'main' into nextjs-suspense-fixes
TkDodo b630bdc
Merge branch 'main' into nextjs-suspense-fixes
TkDodo bb51270
refactor: no need for refs if we don't have effects
TkDodo c2d404b
Merge branch 'main' into nextjs-suspense-fixes
TkDodo 67121b6
Merge branch 'main' into nextjs-suspense-fixes
TkDodo e895537
Merge branch 'main' into nextjs-suspense-fixes
TkDodo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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'm not super on top of the
react-query-next-experimentallibrary so not sure if use cases and edge cases align, but, I thought I'd note that it might be worth checking out this comment (and implementation) in theHydrationBoundaryfor how we handle hydration there: https://github.com/TanStack/query/blob/main/packages/react-query/src/HydrationBoundary.tsx#L35-L49Short version, what we do there is that if data is not already in the cache, we hydrate in render, if it is, we hydrate in an effect so we don't cause side effects inside of render.
I'm not sure how likely this is to happen with the streaming library, if it can at all, but I thought I'd mention it.
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.
Interesting callout! I think it's a different situation here, and what we're doing is safe.
HydrationBoundarycould happen at any part of the tree, whereas there will only be oneReactQueryStreamedHydrationand it will be high up in the tree / wrapping the whole thing. This code will only be called once on boot, and we went any streamed data to be available ASAP on the initial render phase.Definitely let me know if you see any problems with that logic!
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 also think the whole hydration can only happen once, on the first render, where the cache is still empty. I'd give this a go as-is.
I added a small refactoring commit: bb51270
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.
Thanks for taking this across the finish line @TkDodo!