SkippableQueryFactoryFn
Defined in: react/src/types.ts:651
The function createQueryFactory returns: a QueryFactoryFn that
also takes TanStack Query’s skipToken in place of args, for a component
whose args are not known yet. For skipToken it returns a
SkippedQuery, whose useQuery() waits without fetching, in an
entry of its own under the factory’s getQueryKey() prefix. Given
args ? [args] : skipToken, it returns either, and useQuery() can be
called on the result directly.
createSuspenseQueryFactory returns a plain QueryFactoryFn: a
suspense query cannot wait on skipToken.
Example
Section titled “Example”const getBalance = createQueryFactory(ledger, { functionName: "icrc1_balance_of",})
function Balance({ owner }: { owner?: string }) { const { data } = getBalance(owner ? [{ owner }] : skipToken).useQuery()}Extends
Section titled “Extends”Type Parameters
Section titled “Type Parameters”TArgs
The method’s arguments
TQuery
Section titled “TQuery”TQuery extends object
The query object it returns for args
Call Signature
Section titled “Call Signature”SkippableQueryFactoryFn(
args):TQuery
Defined in: react/src/types.ts:657
The function createQueryFactory returns: a QueryFactoryFn that
also takes TanStack Query’s skipToken in place of args, for a component
whose args are not known yet. For skipToken it returns a
SkippedQuery, whose useQuery() waits without fetching, in an
entry of its own under the factory’s getQueryKey() prefix. Given
args ? [args] : skipToken, it returns either, and useQuery() can be
called on the result directly.
createSuspenseQueryFactory returns a plain QueryFactoryFn: a
suspense query cannot wait on skipToken.
Parameters
Section titled “Parameters”TArgs
Returns
Section titled “Returns”TQuery
Example
Section titled “Example”const getBalance = createQueryFactory(ledger, { functionName: "icrc1_balance_of",})
function Balance({ owner }: { owner?: string }) { const { data } = getBalance(owner ? [{ owner }] : skipToken).useQuery()}Call Signature
Section titled “Call Signature”SkippableQueryFactoryFn(
args):SkippedQuery<TQuery>
Defined in: react/src/types.ts:658
The function createQueryFactory returns: a QueryFactoryFn that
also takes TanStack Query’s skipToken in place of args, for a component
whose args are not known yet. For skipToken it returns a
SkippedQuery, whose useQuery() waits without fetching, in an
entry of its own under the factory’s getQueryKey() prefix. Given
args ? [args] : skipToken, it returns either, and useQuery() can be
called on the result directly.
createSuspenseQueryFactory returns a plain QueryFactoryFn: a
suspense query cannot wait on skipToken.
Parameters
Section titled “Parameters”typeof skipToken
Returns
Section titled “Returns”SkippedQuery<TQuery>
Example
Section titled “Example”const getBalance = createQueryFactory(ledger, { functionName: "icrc1_balance_of",})
function Balance({ owner }: { owner?: string }) { const { data } = getBalance(owner ? [{ owner }] : skipToken).useQuery()}Call Signature
Section titled “Call Signature”SkippableQueryFactoryFn(
args):TQuery|SkippedQuery<TQuery>
Defined in: react/src/types.ts:659
The function createQueryFactory returns: a QueryFactoryFn that
also takes TanStack Query’s skipToken in place of args, for a component
whose args are not known yet. For skipToken it returns a
SkippedQuery, whose useQuery() waits without fetching, in an
entry of its own under the factory’s getQueryKey() prefix. Given
args ? [args] : skipToken, it returns either, and useQuery() can be
called on the result directly.
createSuspenseQueryFactory returns a plain QueryFactoryFn: a
suspense query cannot wait on skipToken.
Parameters
Section titled “Parameters”typeof skipToken | TArgs
Returns
Section titled “Returns”TQuery | SkippedQuery<TQuery>
Example
Section titled “Example”const getBalance = createQueryFactory(ledger, { functionName: "icrc1_balance_of",})
function Balance({ owner }: { owner?: string }) { const { data } = getBalance(owner ? [{ owner }] : skipToken).useQuery()}Call Signature
Section titled “Call Signature”SkippableQueryFactoryFn(
args):TQuery
Defined in: react/src/types.ts:666
The function createQueryFactory returns: a QueryFactoryFn that
also takes TanStack Query’s skipToken in place of args, for a component
whose args are not known yet. For skipToken it returns a
SkippedQuery, whose useQuery() waits without fetching, in an
entry of its own under the factory’s getQueryKey() prefix. Given
args ? [args] : skipToken, it returns either, and useQuery() can be
called on the result directly.
createSuspenseQueryFactory returns a plain QueryFactoryFn: a
suspense query cannot wait on skipToken.
Parameters
Section titled “Parameters”TArgs
Returns
Section titled “Returns”TQuery
Example
Section titled “Example”const getBalance = createQueryFactory(ledger, { functionName: "icrc1_balance_of",})
function Balance({ owner }: { owner?: string }) { const { data } = getBalance(owner ? [{ owner }] : skipToken).useQuery()}Properties
Section titled “Properties”getQueryKey
Section titled “getQueryKey”getQueryKey: () => readonly
unknown[]
Defined in: react/src/types.ts:562
The key prefix every query of this factory shares, whatever its args: the
canister (the config’s callConfig.canisterId, else the reactor’s) and
the method, plus the reactor’s transform segment and any agent or
effective-target segment the config’s callConfig adds, and for an
infinite factory its config queryKey. TanStack Query matches keys by
prefix, so the prefix covers every args instance and every infinite page
set. Queries of the same method made elsewhere share it too.
Returns
Section titled “Returns”readonly unknown[]
Example
Section titled “Example”const getBalance = createQueryFactory(ledger, { functionName: "icrc1_balance_of",})
// Every cached balance, whatever the accountledger.queryClient.getQueriesData({ queryKey: getBalance.getQueryKey() })Inherited from
Section titled “Inherited from”QueryFactoryMethods.getQueryKey
invalidate
Section titled “invalidate”invalidate: () =>
Promise<void>
Defined in: react/src/types.ts:574
Invalidate every query of this factory, whatever its args, on the reactor’s QueryClient. It resolves once the active ones have refetched; a refetch that fails does not reject it.
Returns
Section titled “Returns”Promise<void>
Example
Section titled “Example”// After a transfer, refresh every balance on screenawait getBalance.invalidate()