-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(react-query): useSuspenseQuery (#5739)
* feat: useSuspenseQuery * feat: infiniteQueryOptions * fix: add exports * feat: useSuspenseInfiniteQuery * feat: initialData overloads for useInfiniteQuery * fix: types * chore: stabilize test we sometimes get failureCount: 2, but it doesn't matter here (timing issue) * fix: types for useSuspenseQuery (#5755) * docs: suspense * docs: api reference * docs: useSuspenseQuery in examples * fix: types for useSuspenseInfiniteQuery (#5766) --------- Co-authored-by: Jonghyeon Ko <manudeli.ko@gmail.com>
- Loading branch information
Showing
16 changed files
with
364 additions
and
24 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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 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 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 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 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 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.