-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
fix(react-query/HydrationBoundary): prevent unnecessary refetch during hydration #9968
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
Open
sukvvon
wants to merge
37
commits into
TanStack:main
Choose a base branch
from
sukvvon:fix/hydration-boundary-double-fetch
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
37 commits
Select commit
Hold shift + click to select a range
8626d42
fix(react-query/HydrationBoundary): prevent unnecessary refetch durin…
sukvvon 25499fc
Merge branch 'main' into fix/hydration-boundary-double-fetch
sukvvon 695fa28
chore(.changeset): change version bump from 'patch' to 'minor'
sukvvon 2738c99
refactor(react-query/HydrationBoundary): add useEffect cleanup and ex…
sukvvon 9267ccc
Merge branch 'main' into fix/hydration-boundary-double-fetch
sukvvon 992bee3
Merge branch 'main' into fix/hydration-boundary-double-fetch
sukvvon b8f5e0a
Merge branch 'main' into fix/hydration-boundary-double-fetch
sukvvon 9d64cf1
Merge branch 'main' into fix/hydration-boundary-double-fetch
sukvvon bcd214e
chore(.changeset): change version bump from 'minor' to 'patch'
sukvvon 607f405
Merge branch 'main' into fix/hydration-boundary-double-fetch
sukvvon aa4c923
Merge branch 'main' into fix/hydration-boundary-double-fetch
sukvvon 653df2c
Merge branch 'main' into fix/hydration-boundary-double-fetch
sukvvon 08715e6
Merge branch 'main' into fix/hydration-boundary-double-fetch
sukvvon d3bf064
Merge branch 'main' into fix/hydration-boundary-double-fetch
sukvvon 2a65e27
Merge branch 'main' into fix/hydration-boundary-double-fetch
sukvvon 78ce3f5
Merge branch 'main' into fix/hydration-boundary-double-fetch
sukvvon 058fee0
refactor(react-query): replace global 'pendingHydrationQueries' with …
sukvvon cdbc754
ci: apply automated fixes
autofix-ci[bot] f840a0a
fix(query-core): refetch stale data during hydration for cached marku…
sukvvon bb9cced
docs(react): update hydration docs to reflect stale data refetch beha…
sukvvon b63f6ec
refactor(react-query/IsHydratingProvider): simplify context definition
sukvvon c4ad620
refactor(react-query): simplify hydration context from '{ current: Se…
sukvvon 888f65a
Merge branch 'main' into fix/hydration-boundary-double-fetch
sukvvon 555e2b9
Merge branch 'main' into fix/hydration-boundary-double-fetch
sukvvon 5fec087
ci: trigger CI
sukvvon 8da1001
Merge branch 'main' into fix/hydration-boundary-double-fetch
sukvvon a8d3c99
Merge branch 'main' into fix/hydration-boundary-double-fetch
sukvvon 2faa447
Merge branch 'main' into fix/hydration-boundary-double-fetch
sukvvon 2362ae8
Merge branch 'main' into fix/hydration-boundary-double-fetch
sukvvon c37ad5e
Merge branch 'main' into fix/hydration-boundary-double-fetch
sukvvon 95d9f86
Merge branch 'main' into fix/hydration-boundary-double-fetch
sukvvon e7e6882
Merge branch 'main' into fix/hydration-boundary-double-fetch
sukvvon dba4b76
Merge branch 'main' into fix/hydration-boundary-double-fetch
sukvvon e6c8ad8
Merge branch 'main' into fix/hydration-boundary-double-fetch
sukvvon e4c589f
fix(react-query/HydrationBoundary): derive pending hydration set in r…
sukvvon 8ab4e34
fix(query-core/queryObserver): match the server on the first hydratin…
sukvvon 8c1d38f
Merge branch 'main' into fix/hydration-boundary-double-fetch
sukvvon 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| --- | ||
| '@tanstack/query-core': patch | ||
| '@tanstack/react-query': patch | ||
| --- | ||
|
|
||
| fix(react-query/HydrationBoundary): prevent unnecessary refetch during hydration |
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| 'use client' | ||
| import * as React from 'react' | ||
|
|
||
| const IsHydratingContext = React.createContext<ReadonlySet<string>>(new Set()) | ||
|
|
||
| export const useIsHydrating = () => React.useContext(IsHydratingContext) | ||
| export const IsHydratingProvider = IsHydratingContext.Provider |
Oops, something went wrong.
Oops, something went wrong.
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.
There's also logic in
createResultthat needs to account for this. That's also used to determine what state the query will be in, the optimistic result that the query hooks see on first render, before this is called and the actual fetch (possibly) happens.This gets into some other tricky territory (where we might already have other bugs tbh), which is that the first render needs to match the render on the server. If the data was not stale when server rendering, but is now stale, we need to: