Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 4.2k
Preact: update usePrefetchQuery to use new methods with docs#10669
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
TkDodo
merged 8 commits into
TanStack:main
from
DogPawHat:simplified-query-methods/preact-docsAug 20, 2026
+180
−38
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
56870c8
feat(preact-query): use new methods for usePrefetchQuery plus tests
DogPawHat 7b642e1
docs(preact-query): updated docs for usePrefetchQuery
DogPawHat b1ae253
Update docs/framework/preact/reference/interfaces/UsePrefetchInfinite…
DogPawHat 8cf3459
Update packages/preact-query/src/usePrefetchInfiniteQuery.tsx
DogPawHat 9f2e021
Update packages/preact-query/src/usePrefetchQuery.tsx
DogPawHat d766071
Merge branch 'main' into simplified-query-methods/preact-docs
DogPawHat 87bd110
Merge branch 'main' into simplified-query-methods/preact-docs
DogPawHat 4f22091
Merge branch 'main' into simplified-query-methods/preact-docs
DogPawHat File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading. Please reload this page.
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,5 @@ | ||
| --- | ||
| '@tanstack/preact-query': minor | ||
| --- | ||
| preact-query: update usePrefetchQuery and usePrefetchInfiniteQuery to use queryClient.query and queryClient.infiniteQuery |
4 changes: 2 additions & 2 deletions
4 docs/framework/preact/reference/functions/usePrefetchInfiniteQuery.md
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
10 changes: 7 additions & 3 deletions
10 docs/framework/preact/reference/functions/usePrefetchQuery.md
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
40 changes: 40 additions & 0 deletions
40 docs/framework/preact/reference/interfaces/UsePrefetchInfiniteQueryOptions.md
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,40 @@ | ||
| --- | ||
| id: UsePrefetchInfiniteQueryOptions | ||
| title: UsePrefetchInfiniteQueryOptions | ||
| --- | ||
| ```ts | ||
| type UsePrefetchInfiniteQueryOptions<TQueryFnData, TError, TData, TQueryKey, TPageParam> | ||
| ``` | ||
| Defined in: [preact-query/src/types.ts:72](https://github.com/TanStack/query/blob/main/packages/preact-query/src/types.ts#L72) | ||
| ## Type Declaration | ||
| ### queryFn? | ||
| ```ts | ||
| optional queryFn: QueryFunction<TQueryFnData, TQueryKey, TPageParam>; | ||
| ``` | ||
| ## Type Parameters | ||
| ### TQueryFnData | ||
| `TQueryFnData` = `unknown` | ||
| ### TError | ||
| `TError` = `DefaultError` | ||
| ### TData | ||
| `TData` = `TQueryFnData` | ||
| ### TQueryKey | ||
| `TQueryKey` *extends* `QueryKey` = `QueryKey` | ||
| ### TPageParam | ||
| `TPageParam` = `unknown` |
28 changes: 15 additions & 13 deletions
28 docs/framework/preact/reference/interfaces/UsePrefetchQueryOptions.md
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
12 changes: 12 additions & 0 deletions
12 packages/preact-query/src/__tests__/useInfiniteQuery.test-d.tsx
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
23 changes: 22 additions & 1 deletion
23 packages/preact-query/src/__tests__/usePrefetchInfiniteQuery.test-d.tsx
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
16 changes: 16 additions & 0 deletions
16 packages/preact-query/src/__tests__/usePrefetchQuery.test-d.tsx
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 |
|---|---|---|
| @@ -1,20 +1,28 @@ | ||
| import type { DefaultError, QueryClient, QueryKey } from '@tanstack/query-core' | ||
| import { noop } from '@tanstack/query-core' | ||
| import { useQueryClient } from './QueryClientProvider' | ||
| import type { DefaultError, QueryClient, QueryKey } from '@tanstack/query-core' | ||
| import type { UsePrefetchQueryOptions } from './types' | ||
| export function usePrefetchQuery< | ||
| TQueryFnData = unknown, | ||
| TError = DefaultError, | ||
| TData = TQueryFnData, | ||
| TQueryData = TQueryFnData, | ||
| TQueryKey extends QueryKey = QueryKey, | ||
| >( | ||
| options: UsePrefetchQueryOptions<TQueryFnData, TError, TData, TQueryKey>, | ||
| options: UsePrefetchQueryOptions< | ||
| TQueryFnData, | ||
| TError, | ||
| TData, | ||
| TQueryData, | ||
| TQueryKey | ||
| >, | ||
| queryClient?: QueryClient, | ||
| ) { | ||
| const client = useQueryClient(queryClient) | ||
| if (!client.getQueryState(options.queryKey)) { | ||
| client.prefetchQuery(options) | ||
| void client.fetchQuery(options).catch(noop) | ||
| } | ||
| } |
Oops, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
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.
Uh oh!
There was an error while loading. Please reload this page.