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

Reference / @getenginex/sdk-react / useEnginexQueries

useEnginexQueries() ​

Call Signature ​

useEnginexQueries(): CoreQueries

Core query factories, memoized per client: the same object across renders while the EnginexProvider client stays the same. Each call (q.wallet.getBalance()) returns the options with the user key as of the call; call it on every render (as in the example) so the key follows a user switch, instead of storing the result.

With (factory, product) it returns the factories of a product package (see the other signature).

Returns ​

CoreQueries

The core query factories.

Throws ​

If called outside an EnginexProvider.

Example ​

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

Call Signature ​

useEnginexQueries<P, Q>(factory, product): Q

Query factories of a product package (createIgamingQueries, createPredictionsQueries), memoized per factory and product: the same object across renders while both stay the same. As in the core, call each factory on every render.

Type Parameters ​

P ​

P

Q ​

Q

Parameters ​

factory ​

(product) => Q

Product factory, e.g. createIgamingQueries.

product ​

P

The product object, e.g. the one returned by createIgaming(enginex).

Returns ​

Q

The product query factories.

Throws ​

If called outside an EnginexProvider.

Example ​

ts
const ig = useEnginexQueries(createIgamingQueries, igaming)
const games = useEnginexQuery(ig.casino.listGames({ page: 1 }))