Download react-query/docs/framework/angular/reference/functions/queryoptions.md from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 4.69 kB
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/react-query/docs/framework/angular/reference/functions/queryoptions.md
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset@1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/react-query/docs/framework/angular/reference/functions/queryoptions.md
-
curl -L -o queryoptions.md https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/react-query/docs/framework/angular/reference/functions/queryoptions.md
id: queryOptions
title: queryOptions
Function: queryOptions()
Allows to share and re-use query options in a type-safe way.
The queryKey will be tagged with the type from queryFn.
Example
const { queryKey } = queryOptions({
queryKey: ['key'],
queryFn: () => Promise.resolve(5),
// ^? Promise<number>
})
const queryClient = new QueryClient()
const data = queryClient.getQueryData(queryKey)
// ^? number | undefined
Param
The query options to tag with the type from queryFn.
Call Signature
function queryOptions<TQueryFnData, TError, TData, TQueryKey>(
options,
): DefinedInitialDataOptions<TQueryFnData, TError, TData, TQueryKey> & object
Allows to share and re-use query options in a type-safe way.
The queryKey will be tagged with the type from queryFn.
Example
const { queryKey } = queryOptions({
queryKey: ['key'],
queryFn: () => Promise.resolve(5),
// ^? Promise<number>
})
const queryClient = new QueryClient()
const data = queryClient.getQueryData(queryKey)
// ^? number | undefined
Type Parameters
• TQueryFnData = unknown
• TError = Error
• TData = TQueryFnData
• TQueryKey extends readonly unknown[] = readonly unknown[]
Parameters
options
DefinedInitialDataOptions<TQueryFnData, TError, TData, TQueryKey>
The query options to tag with the type from queryFn.
Returns
DefinedInitialDataOptions<TQueryFnData, TError, TData, TQueryKey> & object
The tagged query options.
The tagged query options.
Param
The query options to tag with the type from queryFn.
Defined in
Call Signature
function queryOptions<TQueryFnData, TError, TData, TQueryKey>(
options,
): UnusedSkipTokenOptions<TQueryFnData, TError, TData, TQueryKey> & object
Allows to share and re-use query options in a type-safe way.
The queryKey will be tagged with the type from queryFn.
Example
const { queryKey } = queryOptions({
queryKey: ['key'],
queryFn: () => Promise.resolve(5),
// ^? Promise<number>
})
const queryClient = new QueryClient()
const data = queryClient.getQueryData(queryKey)
// ^? number | undefined
Type Parameters
• TQueryFnData = unknown
• TError = Error
• TData = TQueryFnData
• TQueryKey extends readonly unknown[] = readonly unknown[]
Parameters
options
UnusedSkipTokenOptions<TQueryFnData, TError, TData, TQueryKey>
The query options to tag with the type from queryFn.
Returns
UnusedSkipTokenOptions<TQueryFnData, TError, TData, TQueryKey> & object
The tagged query options.
The tagged query options.
Param
The query options to tag with the type from queryFn.
Defined in
Call Signature
function queryOptions<TQueryFnData, TError, TData, TQueryKey>(
options,
): UndefinedInitialDataOptions<TQueryFnData, TError, TData, TQueryKey> & object
Allows to share and re-use query options in a type-safe way.
The queryKey will be tagged with the type from queryFn.
Example
const { queryKey } = queryOptions({
queryKey: ['key'],
queryFn: () => Promise.resolve(5),
// ^? Promise<number>
})
const queryClient = new QueryClient()
const data = queryClient.getQueryData(queryKey)
// ^? number | undefined
Type Parameters
• TQueryFnData = unknown
• TError = Error
• TData = TQueryFnData
• TQueryKey extends readonly unknown[] = readonly unknown[]
Parameters
options
UndefinedInitialDataOptions<TQueryFnData, TError, TData, TQueryKey>
The query options to tag with the type from queryFn.
Returns
UndefinedInitialDataOptions<TQueryFnData, TError, TData, TQueryKey> & object
The tagged query options.
The tagged query options.
Param
The query options to tag with the type from queryFn.