-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
feat(react-query): useSuspenseQuery #5739
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
17 commits
Select commit
Hold shift + click to select a range
12b53a4
feat: useSuspenseQuery
TkDodo bd93c67
feat: infiniteQueryOptions
TkDodo e7cc229
fix: add exports
TkDodo 6bb924f
feat: useSuspenseInfiniteQuery
TkDodo 28168a3
feat: initialData overloads for useInfiniteQuery
TkDodo 051ade4
Merge branch 'alpha' into feature/use-suspense-query
TkDodo bd6aa3a
fix: types
TkDodo 3f9f6d0
chore: stabilize test
TkDodo 0c0055c
Merge branch 'alpha' into feature/use-suspense-query
TkDodo a8ae890
fix: types for useSuspenseQuery (#5755)
manudeli de8bbb0
Merge branch 'alpha' into feature/use-suspense-query
TkDodo bd7126e
docs: suspense
TkDodo cd244aa
docs: api reference
TkDodo 38e92a4
docs: useSuspenseQuery in examples
TkDodo d5c2a8e
fix: types for useSuspenseInfiniteQuery (#5766)
manudeli 24dcb26
Merge remote-tracking branch 'origin/feature/use-suspense-query' into…
TkDodo dbb7306
Merge branch 'alpha' into feature/use-suspense-query
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
--- | ||
id: useSuspenseInfiniteQuery | ||
title: useSuspenseInfiniteQuery | ||
--- | ||
|
||
```tsx | ||
const result = useSuspenseInfiniteQuery(options) | ||
``` | ||
|
||
**Options** | ||
|
||
The same as for [useInfiniteQuery](../reference/useInfiniteQuery), except for: | ||
- `suspense` | ||
- `throwOnError` | ||
- `enabled` | ||
- `placeholderData` | ||
|
||
**Returns** | ||
|
||
Same object as [useInfiniteQuery](../reference/useInfiniteQuery), except for: | ||
- `isPlaceholderData` is missing | ||
- `status` is always `success` | ||
- the derived flags are set accordingly. |
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,23 @@ | ||
--- | ||
id: useSuspenseQuery | ||
title: useSuspenseQuery | ||
--- | ||
|
||
```tsx | ||
const result = useSuspenseQuery(options) | ||
``` | ||
|
||
**Options** | ||
|
||
The same as for [useQuery](../reference/useQuery), except for: | ||
- `suspense` | ||
- `throwOnError` | ||
- `enabled` | ||
- `placeholderData` | ||
|
||
**Returns** | ||
|
||
Same object as [useQuery](../reference/useQuery), except for: | ||
- `isPlaceholderData` is missing | ||
- `status` is always `success` | ||
- the derived flags are set accordingly. |
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
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,93 @@ | ||
import type { InfiniteData } from '@tanstack/query-core' | ||
import type { UseInfiniteQueryOptions } from './types' | ||
import type { DefaultError, QueryKey } from '@tanstack/query-core' | ||
|
||
export type UndefinedInitialDataInfiniteOptions< | ||
TQueryFnData = unknown, | ||
TError = DefaultError, | ||
TData = TQueryFnData, | ||
TQueryData = TQueryFnData, | ||
TQueryKey extends QueryKey = QueryKey, | ||
TPageParam = unknown, | ||
> = UseInfiniteQueryOptions< | ||
TQueryFnData, | ||
TError, | ||
TData, | ||
TQueryData, | ||
TQueryKey, | ||
TPageParam | ||
> & { | ||
initialData?: undefined | ||
} | ||
|
||
export type DefinedInitialDataInfiniteOptions< | ||
TQueryFnData = unknown, | ||
TError = DefaultError, | ||
TData = TQueryFnData, | ||
TQueryData = TQueryFnData, | ||
TQueryKey extends QueryKey = QueryKey, | ||
TPageParam = unknown, | ||
> = UseInfiniteQueryOptions< | ||
TQueryFnData, | ||
TError, | ||
TData, | ||
TQueryData, | ||
TQueryKey, | ||
TPageParam | ||
> & { | ||
initialData: InfiniteData<TQueryData> | (() => InfiniteData<TQueryData>) | ||
} | ||
|
||
export function infiniteQueryOptions< | ||
TQueryFnData = unknown, | ||
TError = DefaultError, | ||
TData = TQueryFnData, | ||
TQueryData = TQueryFnData, | ||
TQueryKey extends QueryKey = QueryKey, | ||
TPageParam = unknown, | ||
>( | ||
options: UndefinedInitialDataInfiniteOptions< | ||
TQueryFnData, | ||
TError, | ||
TData, | ||
TQueryFnData, | ||
TQueryKey, | ||
TPageParam | ||
>, | ||
): UndefinedInitialDataInfiniteOptions< | ||
TQueryFnData, | ||
TError, | ||
TData, | ||
TQueryFnData, | ||
TQueryKey, | ||
TPageParam | ||
> | ||
|
||
export function infiniteQueryOptions< | ||
TQueryFnData = unknown, | ||
TError = DefaultError, | ||
TData = TQueryFnData, | ||
TQueryData = TQueryFnData, | ||
TQueryKey extends QueryKey = QueryKey, | ||
TPageParam = unknown, | ||
>( | ||
options: DefinedInitialDataInfiniteOptions< | ||
TQueryFnData, | ||
TError, | ||
TData, | ||
TQueryFnData, | ||
TQueryKey, | ||
TPageParam | ||
>, | ||
): DefinedInitialDataInfiniteOptions< | ||
TQueryFnData, | ||
TError, | ||
TData, | ||
TQueryFnData, | ||
TQueryKey, | ||
TPageParam | ||
> | ||
|
||
export function infiniteQueryOptions(options: unknown) { | ||
return options | ||
} |
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.
Uh oh!
There was an error while loading. Please reload this page.