This version (v0.7) has not been published to npm yet.
Skip to content

Reference / @getenginex/sdk-react / useEnginexQuery

useEnginexQuery() ​

useEnginexQuery<T, TSelect>(options, overrides?): UseQueryResult<TSelect, EnginexError>

TanStack useQuery over the options of an SDK factory, with the error typed as EnginexError. The overrides (refetchInterval, select, enabled, staleTime, retry...) win over the factory options, except queryKey and queryFn.

  • Cancellation: unmounting the last component observing the query aborts the SDK fetch (TanStack's signal reaches the request) and raises no error.
  • Retry: an UNAUTHENTICATED (user query without a session, or of another user) is not repeated, since it made no request; other errors follow the app's QueryClient retry. overrides.retry wins over both.

Type Parameters ​

T ​

T

TSelect ​

TSelect = T

Parameters ​

options ​

EnginexQueryOptions<T>

Options of a factory (q.wallet.getBalance()); call the factory on every render.

overrides? ​

Omit<UseQueryOptions<T, EnginexError, TSelect, readonly unknown[]>, "queryKey" | "queryFn">

useQuery options that override the factory's.

Returns ​

UseQueryResult<TSelect, EnginexError>

The useQuery result, with error typed as EnginexError.

Throws ​

If called outside an EnginexProvider (or a QueryClientProvider).

Example ​

ts
const q = useEnginexQueries()
const { data, error } = useEnginexQuery(q.wallet.getBalance(), { refetchInterval: 10_000 })