-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
Added useSuspenseQuery hook, remove top-level suspense: true #11746
Conversation
@@ -27,6 +27,5 @@ export const useDocumentation = (documentationUrl: string): UseDocumentationResu | |||
refetchOnMount: false, | |||
refetchOnWindowFocus: false, | |||
retry: false, | |||
suspense: false, |
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.
Suspense defaults to false now
@@ -42,7 +39,6 @@ export const useGetDestinationDefinitionSpecificationAsync = ( | |||
|
|||
const escapedId = id ?? ""; | |||
return useQuery(destinationDefinitionSpecificationKeys.detail(escapedId), () => service.get(escapedId), { | |||
suspense: false, |
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.
Suspense defaults to false now
@@ -42,7 +39,6 @@ export const useGetSourceDefinitionSpecificationAsync = ( | |||
|
|||
const escapedId = id ?? ""; | |||
return useQuery(sourceDefinitionSpecificationKeys.detail(escapedId), () => service.get(escapedId), { | |||
suspense: false, |
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.
Suspense defaults to false now
) { | ||
return useQuery<TQueryFnData, TError, TData, TQueryKey>(queryKey, queryFn, { | ||
...options, | ||
suspense: true, |
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.
Force suspense for the hook
return useQuery<TQueryFnData, TError, TData, TQueryKey>(queryKey, queryFn, { | ||
...options, | ||
suspense: true, | ||
}).data as typeof options extends Disabled ? TData | undefined : TData; |
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.
We sometimes disable the call due to the rule of hooks. This lets typescript correctly infer the return type.
@@ -5,7 +5,6 @@ import { ReactQueryDevtools } from "react-query/devtools"; | |||
const queryClient = new QueryClient({ | |||
defaultOptions: { | |||
queries: { | |||
suspense: true, |
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.
Defaults to false now since we have the new suspense hook.
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.
Tested several parts of the UI (Cloud mode), nothing seemed to break. Code LGTM
What
Removed the top-level Suspense configuration in favor of a useSuspenseQuery hook, swapping-in-place where appropriate.
No need for
as QueryObserverSuccessResult<T>).data
any more.