Private
dispatchPrivate
executePrivate
mutationPrivate
observersPrivate
Optional
retryerOptional
options: CancelOptionsOptional
revertOptional
silentProtected
fetchOptional
fetchOptions: ObserverFetchOptionsProtected
listenersProtected
bindProtected
createOptional
options: FetchNextPageOptionsOptional
options: FetchPreviousPageOptionsOptional
options: ResultOptionsProtected
onProtected
onOptional
options: RefetchOptions & RefetchQueryFilters<TPageData>Optional
options: InfiniteQueryObserverOptions<TQueryFnData, TError, TData, TQueryData, QueryKey>Optional
notifyOptions: NotifyOptionsOptional
config: MutationCacheConfigProtected
listenersPrivate
mutationPrivate
mutationsOptional
state: MutationState<TData, TError, TVariables, TContext>Optional
mutation: Mutation<any, any, any, any>Protected
onProtected
onPrivate
clientPrivate
Optional
currentPrivate
currentProtected
listenersPrivate
Optional
mutatePrivate
notifyPrivate
updateProtected
bindOptional
variables: TVariablesOptional
options: MutateOptions<TData, TError, TVariables, TContext>Protected
onProtected
onOptional
options: MutationObserverOptions<TData, TError, TVariables, TContext>Optional
listener: MutationObserverListener<TData, TError, TVariables, TContext>Optional
queries: QueryObserverOptions<unknown, unknown, unknown, unknown, QueryKey>[]Private
clientPrivate
findPrivate
getProtected
listenersPrivate
notifyPrivate
observersPrivate
observersPrivate
onPrivate
queriesPrivate
resultPrivate
updateProtected
onProtected
onOptional
notifyOptions: NotifyOptionsPrivate
abortPrivate
cachePrivate
clearPrivate
Optional
defaultPrivate
dispatchPrivate
Optional
gcPrivate
hadPrivate
observersPrivate
optionalPrivate
Optional
promisePrivate
Optional
retryerOptional
revertPrivate
schedulePrivate
setOptional
options: CancelOptionsOptional
options: QueryOptions<TQueryFnData, TError, TData, TQueryKey>Optional
fetchOptions: FetchOptionsProtected
getProtected
reducerOptional
options: SetDataOptionsOptional
config: QueryCacheConfigProtected
listenersPrivate
queriesPrivate
queriesOptional
state: QueryState<TData, TError>Optional
arg2: QueryFiltersOptional
queryKey: QueryKeyOptional
filters: QueryFiltersOptional
filters: QueryFiltersOptional
arg1: QueryKey | QueryFiltersOptional
arg2: QueryFiltersProtected
onProtected
onOptional
config: QueryClientConfigPrivate
defaultPrivate
mutationPrivate
mutationPrivate
queryPrivate
queryPrivate
Optional
unsubscribePrivate
Optional
unsubscribeOptional
filters: QueryFiltersOptional
options: CancelOptionsOptional
queryKey: QueryKeyOptional
filters: QueryFiltersOptional
options: CancelOptionsOptional
options: TOptional
options: QueryObserverOptions<TQueryFnData, TError, TData, TQueryData, TQueryKey>Optional
options: QueryObserverOptions<TQueryFnData, TError, TData, TQueryData, TQueryKey>Optional
options: FetchInfiniteQueryOptions<TQueryFnData, TError, TData, TQueryKey>Optional
options: FetchInfiniteQueryOptions<TQueryFnData, TError, TData, TQueryKey>Optional
options: FetchQueryOptions<TQueryFnData, TError, TData, TQueryKey>Optional
options: FetchQueryOptions<TQueryFnData, TError, TData, TQueryKey>Optional
mutationKey: MutationKeyOptional
queryKey: QueryKeyOptional
filters: InvalidateQueryFilters<TPageData>Optional
options: InvalidateOptionsOptional
queryKey: QueryKeyOptional
filters: InvalidateQueryFilters<TPageData>Optional
options: InvalidateOptionsOptional
filters: QueryFiltersOptional
queryKey: QueryKeyOptional
filters: QueryFiltersOptional
options: FetchInfiniteQueryOptions<TQueryFnData, TError, TData, TQueryKey>Optional
options: FetchInfiniteQueryOptions<TQueryFnData, TError, TData, TQueryKey>Optional
options: FetchQueryOptions<TQueryFnData, TError, TData, TQueryKey>Optional
options: FetchQueryOptions<TQueryFnData, TError, TData, TQueryKey>Optional
filters: RefetchQueryFilters<TPageData>Optional
options: RefetchOptionsOptional
queryKey: QueryKeyOptional
filters: RefetchQueryFilters<TPageData>Optional
options: RefetchOptionsOptional
filters: QueryFiltersOptional
queryKey: QueryKeyOptional
filters: QueryFiltersOptional
filters: ResetQueryFilters<TPageData>Optional
options: ResetOptionsOptional
queryKey: QueryKeyOptional
filters: ResetQueryFilters<TPageData>Optional
options: ResetOptionsOptional
options: SetDataOptionsOptional
options: SetDataOptionsPrivate
clearPrivate
clearPrivate
clearPrivate
clientPrivate
computePrivate
currentPrivate
currentPrivate
Optional
currentPrivate
currentPrivate
Optional
currentPrivate
Optional
currentPrivate
executeProtected
listenersPrivate
notifyPrivate
Optional
previousPrivate
Optional
refetchPrivate
selectPrivate
Optional
selectPrivate
Optional
selectPrivate
shouldPrivate
Optional
stalePrivate
trackedPrivate
updatePrivate
updatePrivate
updatePrivate
updateProtected
bindProtected
createProtected
fetchOptional
fetchOptions: ObserverFetchOptionsOptional
options: ResultOptionsProtected
onProtected
onOptional
options: RefetchOptions & RefetchQueryFilters<TPageData>Optional
options: QueryObserverOptions<TQueryFnData, TError, TData, TQueryData, TQueryKey>Optional
notifyOptions: NotifyOptionsOptional
options: DehydrateOptionsOptional
options: HydrateOptionsAdd support for react query to a subapp
-unknown
-Optional
options: HydrateOptionsOptional
options: Omit<UseInfiniteQueryOptions<TQueryFnData, TError, TData, TQueryFnData, TQueryKey>, "queryKey">Optional
options: Omit<UseInfiniteQueryOptions<TQueryFnData, TError, TData, TQueryFnData, TQueryKey>, "queryKey" | "queryFn">Optional
filters: QueryFiltersOptional
queryKey: QueryKeyOptional
filters: QueryFiltersOptional
filters: MutationFiltersOptional
mutationKey: MutationKeyOptional
filters: Omit<MutationFilters, "mutationKey">Optional
options: Omit<UseMutationOptions<TData, TError, TVariables, TContext>, "mutationFn">Optional
options: Omit<UseMutationOptions<TData, TError, TVariables, TContext>, "mutationKey">Optional
mutationFn: MutationFunction<TData, TVariables>Optional
options: Omit<UseMutationOptions<TData, TError, TVariables, TContext>, "mutationKey" | "mutationFn">Optional
options: Omit<UseQueryOptions<TQueryFnData, TError, TData, TQueryKey>, "queryKey">Optional
options: Omit<UseQueryOptions<TQueryFnData, TError, TData, TQueryKey>, "queryKey" | "queryFn">Add support for react-query to a subapp
-unknown
-@xarc/react-query
This module is part of the Electrode X React Web App platform for using [react-query] in version 2 of its SubApp design.
-Optional
dehydrateOptional
dehydrateOptional
shouldOptional
shouldOptional
defaultOptional
mutations?: MutationOptions<unknown, unknown, void, unknown>Optional
queries?: QueryOptions<unknown, unknown, unknown, QueryKey>Optional
defaultOptional
mutationOptional
queryOptional
refetchOptional
activeInclude or exclude active queries
-Optional
exactMatch query key exactly
-Optional
fetchingInclude or exclude fetching queries
-Optional
inactiveInclude or exclude inactive queries
-Optional
predicateInclude queries matching this predicate function
-Optional
queryInclude queries matching this query key
-Optional
refetchOptional
staleInclude or exclude stale queries
-Optional
activeInclude or exclude active queries
-Optional
exactMatch query key exactly
-Optional
fetchingInclude or exclude fetching queries
-Optional
inactiveInclude or exclude inactive queries
-Optional
predicateInclude queries matching this predicate function
-Optional
queryInclude queries matching this query key
-Optional
refetchOptional
staleInclude or exclude stale queries
-Optional
mutationsOptional
queriesOptional
_defaultedOptional
behaviorOptional
cacheOptional
getThis function can be set to automatically get the next cursor for infinite queries.
-The result will also be used to determine the value of hasNextPage
.
Optional
getThis function can be set to automatically get the previous cursor for infinite queries.
-The result will also be used to determine the value of hasPreviousPage
.
Optional
initialOptional
initialOptional
isOptional
metaAdditional payload to be stored on each query. -Use this property to pass information that can be used in other places.
-Optional
queryOptional
queryOptional
queryOptional
queryOptional
retryIf false
, failed queries will not retry by default.
-If true
, failed queries will retry infinitely., failureCount: num
-If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number.
-If set to a function (failureCount, error) => boolean
failed queries will retry until the function returns false.
Optional
retryOptional
staleThe time in milliseconds after data is considered stale. -If the data is fresh it will be returned from the cache.
-Optional
structuralSet this to false
to disable structural sharing between query results.
-Defaults to true
.
Optional
cancelOptional
pageOptional
throwOptional
cancelOptional
pageOptional
throwOptional
_defaultedOptional
behaviorOptional
cacheOptional
getThis function can be set to automatically get the next cursor for infinite queries.
-The result will also be used to determine the value of hasNextPage
.
Optional
getThis function can be set to automatically get the previous cursor for infinite queries.
-The result will also be used to determine the value of hasPreviousPage
.
Optional
initialOptional
initialOptional
isOptional
metaAdditional payload to be stored on each query. -Use this property to pass information that can be used in other places.
-Optional
queryOptional
queryOptional
queryOptional
queryOptional
retryIf false
, failed queries will not retry by default.
-If true
, failed queries will retry infinitely., failureCount: num
-If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number.
-If set to a function (failureCount, error) => boolean
failed queries will retry until the function returns false.
Optional
retryOptional
staleThe time in milliseconds after data is considered stale. -If the data is fresh it will be returned from the cache.
-Optional
structuralSet this to false
to disable structural sharing between query results.
-Defaults to true
.
Optional
options: FetchNextPageOptionsOptional
options: FetchPreviousPageOptionsOptional
hasOptional
hasOptional
options: RefetchOptions & RefetchQueryFilters<TPageData>Optional
options: FetchNextPageOptionsOptional
options: FetchPreviousPageOptionsOptional
hasOptional
hasOptional
options: RefetchOptions & RefetchQueryFilters<TPageData>Optional
options: FetchNextPageOptionsOptional
options: FetchPreviousPageOptionsOptional
hasOptional
hasOptional
options: RefetchOptions & RefetchQueryFilters<TPageData>Optional
options: FetchNextPageOptionsOptional
options: FetchPreviousPageOptionsOptional
hasOptional
hasOptional
options: RefetchOptions & RefetchQueryFilters<TPageData>Optional
_defaultedOptional
behaviorOptional
cacheOptional
enabledSet this to false
to disable automatic refetching when the query mounts or changes query keys.
-To refetch the query, use the refetch
method returned from the useQuery
instance.
-Defaults to true
.
Optional
getThis function can be set to automatically get the next cursor for infinite queries.
-The result will also be used to determine the value of hasNextPage
.
Optional
getThis function can be set to automatically get the previous cursor for infinite queries.
-The result will also be used to determine the value of hasPreviousPage
.
Optional
initialOptional
initialOptional
isOptional
keepSet this to true
to keep the previous data
when fetching based on a new query key.
-Defaults to false
.
Optional
metaAdditional payload to be stored on each query. -Use this property to pass information that can be used in other places.
-Optional
notifyIf set, the component will only re-render if any of the listed properties change.
-When set to ['data', 'error']
, the component will only re-render when the data
or error
properties change.
-When set to tracked
, access to properties will be tracked, and the component will only re-render when one of the tracked properties change.
Optional
notifyIf set, the component will not re-render if any of the listed properties change.
-Optional
onThis callback will fire if the query encounters an error and will be passed the error.
-Optional
onThis callback will fire any time the query is either successfully fetched or errors and be passed either the data or error.
-Optional
onThis callback will fire any time the query successfully fetches new data or the cache is updated via setQueryData
.
Optional
optimisticIf set, the observer will optimistically set the result in fetching state before the query has actually started fetching.
-This is to make sure the results are not lagging behind.
-Defaults to true
.
Optional
placeholderIf set, this value will be used as the placeholder data for this particular query observer while the query is still in the loading
data and no initialData has been provided.
Optional
queryOptional
queryOptional
queryOptional
queryOptional
refetchIf set to a number, the query will continuously refetch at this frequency in milliseconds.
-If set to a function, the function will be executed with the latest data and query to compute a frequency
-Defaults to false
.
Optional
refetchIf set to true
, the query will continue to refetch while their tab/window is in the background.
-Defaults to false
.
Optional
refetchIf set to true
, the query will refetch on mount if the data is stale.
-If set to false
, will disable additional instances of a query to trigger background refetches.
-If set to 'always'
, the query will always refetch on mount.
-If set to a function, the function will be executed with the latest data and query to compute the value
-Defaults to true
.
Optional
refetchIf set to true
, the query will refetch on reconnect if the data is stale.
-If set to false
, the query will not refetch on reconnect.
-If set to 'always'
, the query will always refetch on reconnect.
-If set to a function, the function will be executed with the latest data and query to compute the value.
-Defaults to true
.
Optional
refetchIf set to true
, the query will refetch on window focus if the data is stale.
-If set to false
, the query will not refetch on window focus.
-If set to 'always'
, the query will always refetch on window focus.
-If set to a function, the function will be executed with the latest data and query to compute the value.
-Defaults to true
.
Optional
retryIf false
, failed queries will not retry by default.
-If true
, failed queries will retry infinitely., failureCount: num
-If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number.
-If set to a function (failureCount, error) => boolean
failed queries will retry until the function returns false.
Optional
retryOptional
retryIf set to false
, the query will not be retried on mount if it contains an error.
-Defaults to true
.
Optional
selectThis option can be used to transform or select a part of the data returned by the query function.
-Optional
staleThe time in milliseconds after data is considered stale.
-If set to Infinity
, the data will never be considered stale.
Optional
structuralSet this to false
to disable structural sharing between query results.
-Defaults to true
.
Optional
suspenseIf set to true
, the query will suspend when status === 'loading'
-and throw errors when status === 'error'
.
-Defaults to false
.
Optional
useWhether errors should be thrown instead of setting the error
property.
-If set to true
or suspense
is true
, all errors will be thrown to the error boundary.
-If set to false
and suspense
is false
, errors are returned as state.
-If set to a function, it will be passed the error and the query, and it should return a boolean indicating whether to show the error in an error boundary (true
) or return the error as state (false
).
-Defaults to false
.
Optional
options: FetchNextPageOptionsOptional
options: FetchPreviousPageOptionsOptional
hasOptional
hasOptional
options: RefetchOptions & RefetchQueryFilters<TPageData>Optional
options: FetchNextPageOptionsOptional
options: FetchPreviousPageOptionsOptional
hasOptional
hasOptional
options: RefetchOptions & RefetchQueryFilters<TPageData>Optional
cancelOptional
throwOptional
activeInclude or exclude active queries
-Optional
exactMatch query key exactly
-Optional
fetchingInclude or exclude fetching queries
-Optional
inactiveInclude or exclude inactive queries
-Optional
predicateInclude queries matching this predicate function
-Optional
queryInclude queries matching this query key
-Optional
refetchOptional
refetchOptional
refetchOptional
staleInclude or exclude stale queries
-Optional
onOptional
onOptional
onOptional
_defaultedOptional
metaOptional
mutationOptional
mutationOptional
onOptional
onOptional
onOptional
onOptional
retryOptional
retryOptional
useOptional
variablesOptional
_defaultedOptional
metaOptional
mutationOptional
mutationOptional
onOptional
onOptional
onOptional
onOptional
retryOptional
retryOptional
variablesOptional
childrenOptional
contextOptional
pageOptional
signalOptional
options: RefetchOptions & RefetchQueryFilters<TPageData>Optional
options: RefetchOptions & RefetchQueryFilters<TPageData>Optional
options: RefetchOptions & RefetchQueryFilters<TPageData>Optional
options: RefetchOptions & RefetchQueryFilters<TPageData>Optional
_defaultedOptional
behaviorOptional
cacheOptional
enabledSet this to false
to disable automatic refetching when the query mounts or changes query keys.
-To refetch the query, use the refetch
method returned from the useQuery
instance.
-Defaults to true
.
Optional
getThis function can be set to automatically get the next cursor for infinite queries.
-The result will also be used to determine the value of hasNextPage
.
Optional
getThis function can be set to automatically get the previous cursor for infinite queries.
-The result will also be used to determine the value of hasPreviousPage
.
Optional
initialOptional
initialOptional
isOptional
keepSet this to true
to keep the previous data
when fetching based on a new query key.
-Defaults to false
.
Optional
metaAdditional payload to be stored on each query. -Use this property to pass information that can be used in other places.
-Optional
notifyIf set, the component will only re-render if any of the listed properties change.
-When set to ['data', 'error']
, the component will only re-render when the data
or error
properties change.
-When set to tracked
, access to properties will be tracked, and the component will only re-render when one of the tracked properties change.
Optional
notifyIf set, the component will not re-render if any of the listed properties change.
-Optional
onThis callback will fire if the query encounters an error and will be passed the error.
-Optional
onThis callback will fire any time the query is either successfully fetched or errors and be passed either the data or error.
-Optional
onThis callback will fire any time the query successfully fetches new data or the cache is updated via setQueryData
.
Optional
optimisticIf set, the observer will optimistically set the result in fetching state before the query has actually started fetching.
-This is to make sure the results are not lagging behind.
-Defaults to true
.
Optional
placeholderIf set, this value will be used as the placeholder data for this particular query observer while the query is still in the loading
data and no initialData has been provided.
Optional
queryOptional
queryOptional
queryOptional
queryOptional
refetchIf set to a number, the query will continuously refetch at this frequency in milliseconds.
-If set to a function, the function will be executed with the latest data and query to compute a frequency
-Defaults to false
.
Optional
refetchIf set to true
, the query will continue to refetch while their tab/window is in the background.
-Defaults to false
.
Optional
refetchIf set to true
, the query will refetch on mount if the data is stale.
-If set to false
, will disable additional instances of a query to trigger background refetches.
-If set to 'always'
, the query will always refetch on mount.
-If set to a function, the function will be executed with the latest data and query to compute the value
-Defaults to true
.
Optional
refetchIf set to true
, the query will refetch on reconnect if the data is stale.
-If set to false
, the query will not refetch on reconnect.
-If set to 'always'
, the query will always refetch on reconnect.
-If set to a function, the function will be executed with the latest data and query to compute the value.
-Defaults to true
.
Optional
refetchIf set to true
, the query will refetch on window focus if the data is stale.
-If set to false
, the query will not refetch on window focus.
-If set to 'always'
, the query will always refetch on window focus.
-If set to a function, the function will be executed with the latest data and query to compute the value.
-Defaults to true
.
Optional
retryIf false
, failed queries will not retry by default.
-If true
, failed queries will retry infinitely., failureCount: num
-If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number.
-If set to a function (failureCount, error) => boolean
failed queries will retry until the function returns false.
Optional
retryOptional
retryIf set to false
, the query will not be retried on mount if it contains an error.
-Defaults to true
.
Optional
selectThis option can be used to transform or select a part of the data returned by the query function.
-Optional
staleThe time in milliseconds after data is considered stale.
-If set to Infinity
, the data will never be considered stale.
Optional
structuralSet this to false
to disable structural sharing between query results.
-Defaults to true
.
Optional
suspenseIf set to true
, the query will suspend when status === 'loading'
-and throw errors when status === 'error'
.
-Defaults to false
.
Optional
useWhether errors should be thrown instead of setting the error
property.
-If set to true
or suspense
is true
, all errors will be thrown to the error boundary.
-If set to false
and suspense
is false
, errors are returned as state.
-If set to a function, it will be passed the error and the query, and it should return a boolean indicating whether to show the error in an error boundary (true
) or return the error as state (false
).
-Defaults to false
.
Optional
options: RefetchOptions & RefetchQueryFilters<TPageData>Optional
options: RefetchOptions & RefetchQueryFilters<TPageData>Optional
_defaultedOptional
behaviorOptional
cacheOptional
getThis function can be set to automatically get the next cursor for infinite queries.
-The result will also be used to determine the value of hasNextPage
.
Optional
getThis function can be set to automatically get the previous cursor for infinite queries.
-The result will also be used to determine the value of hasPreviousPage
.
Optional
initialOptional
initialOptional
isOptional
metaAdditional payload to be stored on each query. -Use this property to pass information that can be used in other places.
-Optional
queryOptional
queryOptional
queryOptional
queryOptional
retryIf false
, failed queries will not retry by default.
-If true
, failed queries will retry infinitely., failureCount: num
-If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number.
-If set to a function (failureCount, error) => boolean
failed queries will retry until the function returns false.
Optional
retryOptional
structuralSet this to false
to disable structural sharing between query results.
-Defaults to true
.
Optional
cancelOptional
throwOptional
cancelOptional
throwOptional
throwOptional
_defaultedOptional
behaviorOptional
cacheOptional
enabledSet this to false
to disable automatic refetching when the query mounts or changes query keys.
-To refetch the query, use the refetch
method returned from the useQuery
instance.
-Defaults to true
.
Optional
getThis function can be set to automatically get the next cursor for infinite queries.
-The result will also be used to determine the value of hasNextPage
.
Optional
getThis function can be set to automatically get the previous cursor for infinite queries.
-The result will also be used to determine the value of hasPreviousPage
.
Optional
initialOptional
initialOptional
isOptional
keepSet this to true
to keep the previous data
when fetching based on a new query key.
-Defaults to false
.
Optional
metaAdditional payload to be stored on each query. -Use this property to pass information that can be used in other places.
-Optional
notifyIf set, the component will only re-render if any of the listed properties change.
-When set to ['data', 'error']
, the component will only re-render when the data
or error
properties change.
-When set to tracked
, access to properties will be tracked, and the component will only re-render when one of the tracked properties change.
Optional
notifyIf set, the component will not re-render if any of the listed properties change.
-Optional
onThis callback will fire if the query encounters an error and will be passed the error.
-Optional
onThis callback will fire any time the query is either successfully fetched or errors and be passed either the data or error.
-Optional
onThis callback will fire any time the query successfully fetches new data or the cache is updated via setQueryData
.
Optional
optimisticIf set, the observer will optimistically set the result in fetching state before the query has actually started fetching.
-This is to make sure the results are not lagging behind.
-Defaults to true
.
Optional
placeholderIf set, this value will be used as the placeholder data for this particular query observer while the query is still in the loading
data and no initialData has been provided.
Optional
queryOptional
queryOptional
queryOptional
queryOptional
refetchIf set to a number, the query will continuously refetch at this frequency in milliseconds.
-If set to a function, the function will be executed with the latest data and query to compute a frequency
-Defaults to false
.
Optional
refetchIf set to true
, the query will continue to refetch while their tab/window is in the background.
-Defaults to false
.
Optional
refetchIf set to true
, the query will refetch on mount if the data is stale.
-If set to false
, will disable additional instances of a query to trigger background refetches.
-If set to 'always'
, the query will always refetch on mount.
-If set to a function, the function will be executed with the latest data and query to compute the value
-Defaults to true
.
Optional
refetchIf set to true
, the query will refetch on reconnect if the data is stale.
-If set to false
, the query will not refetch on reconnect.
-If set to 'always'
, the query will always refetch on reconnect.
-If set to a function, the function will be executed with the latest data and query to compute the value.
-Defaults to true
.
Optional
refetchIf set to true
, the query will refetch on window focus if the data is stale.
-If set to false
, the query will not refetch on window focus.
-If set to 'always'
, the query will always refetch on window focus.
-If set to a function, the function will be executed with the latest data and query to compute the value.
-Defaults to true
.
Optional
retryIf false
, failed queries will not retry by default.
-If true
, failed queries will retry infinitely., failureCount: num
-If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number.
-If set to a function (failureCount, error) => boolean
failed queries will retry until the function returns false.
Optional
retryOptional
retryIf set to false
, the query will not be retried on mount if it contains an error.
-Defaults to true
.
Optional
selectThis option can be used to transform or select a part of the data returned by the query function.
-Optional
staleThe time in milliseconds after data is considered stale.
-If set to Infinity
, the data will never be considered stale.
Optional
structuralSet this to false
to disable structural sharing between query results.
-Defaults to true
.
Optional
suspenseIf set to true
, the query will suspend when status === 'loading'
-and throw errors when status === 'error'
.
-Defaults to false
.
Optional
useWhether errors should be thrown instead of setting the error
property.
-If set to true
or suspense
is true
, all errors will be thrown to the error boundary.
-If set to false
and suspense
is false
, errors are returned as state.
-If set to a function, it will be passed the error and the query, and it should return a boolean indicating whether to show the error in an error boundary (true
) or return the error as state (false
).
-Defaults to false
.
Optional
_defaultedOptional
behaviorOptional
cacheOptional
enabledSet this to false
to disable automatic refetching when the query mounts or changes query keys.
-To refetch the query, use the refetch
method returned from the useQuery
instance.
-Defaults to true
.
Optional
getThis function can be set to automatically get the next cursor for infinite queries.
-The result will also be used to determine the value of hasNextPage
.
Optional
getThis function can be set to automatically get the previous cursor for infinite queries.
-The result will also be used to determine the value of hasPreviousPage
.
Optional
initialOptional
initialOptional
isOptional
keepSet this to true
to keep the previous data
when fetching based on a new query key.
-Defaults to false
.
Optional
metaAdditional payload to be stored on each query. -Use this property to pass information that can be used in other places.
-Optional
notifyIf set, the component will only re-render if any of the listed properties change.
-When set to ['data', 'error']
, the component will only re-render when the data
or error
properties change.
-When set to tracked
, access to properties will be tracked, and the component will only re-render when one of the tracked properties change.
Optional
notifyIf set, the component will not re-render if any of the listed properties change.
-Optional
onThis callback will fire if the query encounters an error and will be passed the error.
-Optional
onThis callback will fire any time the query is either successfully fetched or errors and be passed either the data or error.
-Optional
onThis callback will fire any time the query successfully fetches new data or the cache is updated via setQueryData
.
Optional
optimisticIf set, the observer will optimistically set the result in fetching state before the query has actually started fetching.
-This is to make sure the results are not lagging behind.
-Defaults to true
.
Optional
placeholderIf set, this value will be used as the placeholder data for this particular query observer while the query is still in the loading
data and no initialData has been provided.
Optional
queryOptional
queryOptional
queryOptional
queryOptional
refetchIf set to a number, the query will continuously refetch at this frequency in milliseconds.
-If set to a function, the function will be executed with the latest data and query to compute a frequency
-Defaults to false
.
Optional
refetchIf set to true
, the query will continue to refetch while their tab/window is in the background.
-Defaults to false
.
Optional
refetchIf set to true
, the query will refetch on mount if the data is stale.
-If set to false
, will disable additional instances of a query to trigger background refetches.
-If set to 'always'
, the query will always refetch on mount.
-If set to a function, the function will be executed with the latest data and query to compute the value
-Defaults to true
.
Optional
refetchIf set to true
, the query will refetch on reconnect if the data is stale.
-If set to false
, the query will not refetch on reconnect.
-If set to 'always'
, the query will always refetch on reconnect.
-If set to a function, the function will be executed with the latest data and query to compute the value.
-Defaults to true
.
Optional
refetchIf set to true
, the query will refetch on window focus if the data is stale.
-If set to false
, the query will not refetch on window focus.
-If set to 'always'
, the query will always refetch on window focus.
-If set to a function, the function will be executed with the latest data and query to compute the value.
-Defaults to true
.
Optional
retryIf false
, failed queries will not retry by default.
-If true
, failed queries will retry infinitely., failureCount: num
-If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number.
-If set to a function (failureCount, error) => boolean
failed queries will retry until the function returns false.
Optional
retryOptional
retryIf set to false
, the query will not be retried on mount if it contains an error.
-Defaults to true
.
Optional
selectThis option can be used to transform or select a part of the data returned by the query function.
-Optional
staleThe time in milliseconds after data is considered stale.
-If set to Infinity
, the data will never be considered stale.
Optional
structuralSet this to false
to disable structural sharing between query results.
-Defaults to true
.
Optional
suspenseIf set to true
, the query will suspend when status === 'loading'
-and throw errors when status === 'error'
.
-Defaults to false
.
Optional
useWhether errors should be thrown instead of setting the error
property.
-If set to true
or suspense
is true
, all errors will be thrown to the error boundary.
-If set to false
and suspense
is false
, errors are returned as state.
-If set to a function, it will be passed the error and the query, and it should return a boolean indicating whether to show the error in an error boundary (true
) or return the error as state (false
).
-Defaults to false
.
Optional
metaOptional
mutationOptional
mutationOptional
onOptional
onOptional
onOptional
onOptional
retryOptional
retryOptional
useOptional
_defaultedOptional
behaviorOptional
cacheOptional
enabledSet this to false
to disable automatic refetching when the query mounts or changes query keys.
-To refetch the query, use the refetch
method returned from the useQuery
instance.
-Defaults to true
.
Optional
getThis function can be set to automatically get the next cursor for infinite queries.
-The result will also be used to determine the value of hasNextPage
.
Optional
getThis function can be set to automatically get the previous cursor for infinite queries.
-The result will also be used to determine the value of hasPreviousPage
.
Optional
initialOptional
initialOptional
isOptional
keepSet this to true
to keep the previous data
when fetching based on a new query key.
-Defaults to false
.
Optional
metaAdditional payload to be stored on each query. -Use this property to pass information that can be used in other places.
-Optional
notifyIf set, the component will only re-render if any of the listed properties change.
-When set to ['data', 'error']
, the component will only re-render when the data
or error
properties change.
-When set to tracked
, access to properties will be tracked, and the component will only re-render when one of the tracked properties change.
Optional
notifyIf set, the component will not re-render if any of the listed properties change.
-Optional
onThis callback will fire if the query encounters an error and will be passed the error.
-Optional
onThis callback will fire any time the query is either successfully fetched or errors and be passed either the data or error.
-Optional
onThis callback will fire any time the query successfully fetches new data or the cache is updated via setQueryData
.
Optional
optimisticIf set, the observer will optimistically set the result in fetching state before the query has actually started fetching.
-This is to make sure the results are not lagging behind.
-Defaults to true
.
Optional
placeholderIf set, this value will be used as the placeholder data for this particular query observer while the query is still in the loading
data and no initialData has been provided.
Optional
queryOptional
queryOptional
queryOptional
queryOptional
refetchIf set to a number, the query will continuously refetch at this frequency in milliseconds.
-If set to a function, the function will be executed with the latest data and query to compute a frequency
-Defaults to false
.
Optional
refetchIf set to true
, the query will continue to refetch while their tab/window is in the background.
-Defaults to false
.
Optional
refetchIf set to true
, the query will refetch on mount if the data is stale.
-If set to false
, will disable additional instances of a query to trigger background refetches.
-If set to 'always'
, the query will always refetch on mount.
-If set to a function, the function will be executed with the latest data and query to compute the value
-Defaults to true
.
Optional
refetchIf set to true
, the query will refetch on reconnect if the data is stale.
-If set to false
, the query will not refetch on reconnect.
-If set to 'always'
, the query will always refetch on reconnect.
-If set to a function, the function will be executed with the latest data and query to compute the value.
-Defaults to true
.
Optional
refetchIf set to true
, the query will refetch on window focus if the data is stale.
-If set to false
, the query will not refetch on window focus.
-If set to 'always'
, the query will always refetch on window focus.
-If set to a function, the function will be executed with the latest data and query to compute the value.
-Defaults to true
.
Optional
retryIf false
, failed queries will not retry by default.
-If true
, failed queries will retry infinitely., failureCount: num
-If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number.
-If set to a function (failureCount, error) => boolean
failed queries will retry until the function returns false.
Optional
retryOptional
retryIf set to false
, the query will not be retried on mount if it contains an error.
-Defaults to true
.
Optional
selectThis option can be used to transform or select a part of the data returned by the query function.
-Optional
staleThe time in milliseconds after data is considered stale.
-If set to Infinity
, the data will never be considered stale.
Optional
structuralSet this to false
to disable structural sharing between query results.
-Defaults to true
.
Optional
suspenseIf set to true
, the query will suspend when status === 'loading'
-and throw errors when status === 'error'
.
-Defaults to false
.
Optional
useWhether errors should be thrown instead of setting the error
property.
-If set to true
or suspense
is true
, all errors will be thrown to the error boundary.
-If set to false
and suspense
is false
, errors are returned as state.
-If set to a function, it will be passed the error and the query, and it should return a boolean indicating whether to show the error in an error boundary (true
) or return the error as state (false
).
-Defaults to false
.
Optional
options: MutateOptions<TData, TError, TVariables, TContext>QueriesOptions reducer recursively unwraps function arguments to infer/enforce type param
-QueriesResults reducer recursively maps type param to results
-Rest
...args: Parameters<MutateFunction<TData, TError, TVariables, TContext>>Server module for exporting the prefetchQuery
method
react-query feature options
-The React module.
-This is needed for the react query feature to wrap subapp's component inside -the react query client provider component.
-Optional
exportIf your module export the prefetch query method with a different name than prefetchQuery
,
-then specify it here.
Optional
queryCustom react-query client.
-If not provided, then create from new QueryClient
Optional
serverPath pointing to the module that exports the prefetchQuery
method on the server.
Typically this should be from something like require.resolve("./react-query-prefetch")
Your module will be loaded and executed on the server only and will not be bundled for the -client, and it can use any node.js APIs.
-A typical prefetchQuery
may look like this:
export const prefetchQuery = async ({ queryClient, ssrData }) => {
await queryClient.prefetchQuery("test", testFetch);
const dehydratedState = dehydrate(queryClient);
queryClient.resetQueries();
return { queryClient, dehydratedState };
};
-
-.
-Const
Const
Const
Const
Const
{"msg":"foo","queryKey":["test"]}
`); + const element = await waitFor(() => screen.getByText("test"), { + timeout: 500, + }); + expect(element.innerHTML).contains( + `{"msg":"foo","queryKey":["test"]}
` + ); }); - it("should render subapp with react-query when input component does not exist", async () => { + it("should render subapp with @tanstack/react-query when input component does not exist", async () => { const container = new SubAppContainer({}); envHooks.getContainer = () => container; @@ -102,9 +106,9 @@ describe("reactQueryFeature browser", function () {text
text
`); }); diff --git a/packages/xarc-react-query/test/spec/node-index.spec.tsx b/packages/xarc-react-query/test/spec/node-index.spec.tsx index 0a33ad2e8..51b6364cd 100644 --- a/packages/xarc-react-query/test/spec/node-index.spec.tsx +++ b/packages/xarc-react-query/test/spec/node-index.spec.tsx @@ -5,7 +5,7 @@ import { describe, it } from "mocha"; import { expect } from "chai"; import { renderToString } from "react-dom/server"; import { SubAppDef, SubAppContainer, envHooks } from "@xarc/subapp"; -import { useQuery } from "react-query"; +import { useQuery } from "@tanstack/react-query"; import { reactQueryFeature } from "../../src/node/index"; import { testFetch } from "../prefetch"; import { render, waitFor, screen } from "@testing-library/react"; @@ -16,11 +16,11 @@ describe("reactQueryFeature node.js", function () { it("should return a feature factory", async () => { const factory = reactQueryFeature({ React }); expect(factory.id).equal("state-provider"); - expect(factory.subId).equal("react-query"); + expect(factory.subId).equal("@tanstack/react-query"); expect(factory.add).to.be.a("function"); }); - it("should add react-query feature to a subapp", async () => { + it("should add @tanstack/react-query feature to a subapp", async () => { const container = new SubAppContainer({}); envHooks.getContainer = () => container; const factory = reactQueryFeature({ React }); @@ -29,7 +29,7 @@ describe("reactQueryFeature node.js", function () { getModule() { return Promise.resolve({}); }, - _features: {} + _features: {}, } as SubAppDef; container.declare("test", def); @@ -37,14 +37,14 @@ describe("reactQueryFeature node.js", function () { expect(def._features.reactQuery).to.be.an("object"); }); - it("should render subapp with react-query if it successfully fetches data when doing SSR", async () => { + xit("should render subapp with @tanstack/react-query if it successfully fetches data when doing SSR", async () => { const container = new SubAppContainer({}); envHooks.getContainer = () => container; const factory = reactQueryFeature({ React, - serverModule: require.resolve("../prefetch") + serverModule: require.resolve("../prefetch"), }); const def = { @@ -52,7 +52,7 @@ describe("reactQueryFeature node.js", function () { getModule() { return Promise.resolve({}); }, - _features: {} + _features: {}, } as SubAppDef; container.declare("test", def); @@ -61,36 +61,33 @@ describe("reactQueryFeature node.js", function () { const result = await def._features.reactQuery.execute({ input: { Component: () => { - const { data } = useQuery( - "test", - testFetch, - // ensure react-query doesn't keep node.js running with its timers - { cacheTime: 200 } - ); + const { data } = useQuery({ + queryKey: ["test"], + queryFn: testFetch, + gcTime: 200, + }); return ({JSON.stringify(data)}
{"msg":"foo","queryKey":["test"]}
{JSON.stringify(data)}
{"msg":"foo","queryKey":["test"]}
`); + expect(element.innerHTML).equal( + `test{"msg":"foo","queryKey":["test"]}
` + ); }); - it("should render subapp with react-query if it fails on fetching data when doing SSR", async () => { + it("should render subapp with @tanstack/react-query if it fails on fetching data when doing SSR", async () => { const container = new SubAppContainer({}); envHooks.getContainer = () => container; const factory = reactQueryFeature({ React, - serverModule: undefined + serverModule: undefined, }); const def = { @@ -144,7 +144,7 @@ describe("reactQueryFeature node.js", function () { getModule() { return Promise.resolve({}); }, - _features: {} + _features: {}, } as SubAppDef; container.declare("test", def); @@ -154,36 +154,38 @@ describe("reactQueryFeature node.js", function () { const res = await def._features.reactQuery.execute({ input: { Component: () => { - const { data } = useQuery( - "test", - testFetch, - // ensure react-query doesn't keep node.js running with its timers - { cacheTime: 200 } - ); + const { data } = useQuery({ + queryKey: ["test"], + queryFn: testFetch, + gcTime: 200, + }); return ({JSON.stringify(data)}
{"msg":"foo","queryKey":["test"]}
`); + await new Promise((resolve) => setTimeout(resolve, 1000)); + const element = await waitFor(() => screen.getByText("test"), { + timeout: 500, + }); + expect(element.innerHTML).contains( + `{"msg":"foo","queryKey":["test"]}
` + ); }); - it("should render subapp with react-query when input component does not exist", async () => { + it("should render subapp with @tanstack/react-query when input component does not exist", async () => { const container = new SubAppContainer({}); envHooks.getContainer = () => container; const factory = reactQueryFeature({ React, - serverModule: undefined + serverModule: undefined, }); const def = { @@ -198,9 +200,9 @@ describe("reactQueryFeature node.js", function () {text
text
`); }); diff --git a/packages/xarc-react-query/tsconfig.browser.es5.cjs.json b/packages/xarc-react-query/tsconfig.browser.es5.cjs.json index b8fb8a6f8..bcbc49d77 100644 --- a/packages/xarc-react-query/tsconfig.browser.es5.cjs.json +++ b/packages/xarc-react-query/tsconfig.browser.es5.cjs.json @@ -7,7 +7,7 @@ "module": "CommonJS", "esModuleInterop": true, "importHelpers": true, - "target": "ES5", + "target": "ES6", "preserveConstEnums": true, "sourceMap": true, "declaration": true, diff --git a/samples/subapp2-basic/src/subapps/footer/index.tsx b/samples/subapp2-basic/src/subapps/footer/index.tsx index 305507726..b532776d3 100644 --- a/samples/subapp2-basic/src/subapps/footer/index.tsx +++ b/samples/subapp2-basic/src/subapps/footer/index.tsx @@ -12,7 +12,7 @@ import { demo3QueryFn } from "./react-query-fetch"; import { DisplayInfo } from "./display-info"; const Footer = () => { - const { data } = useQuery("demo3", demo3QueryFn, { staleTime: 2000 }); + const { data } = useQuery({ queryKey: ["demo3"], queryFn: demo3QueryFn, staleTime: 2000 }); return (subapp demo4
data:{JSON.stringify(data)}
@@ -22,7 +33,7 @@ export const subapp: ReactSubApp = { // https://react-query.tanstack.com/docs/overview reactQueryFeature({ React, - serverModule: require.resolve("./demo4-react-query") - }) - ] + serverModule: require.resolve("./demo4-react-query"), + }), + ], };
Default query keys hash function.
-