# BaseQueryResult

Defined in: [react/src/types.ts:227](https://github.com/B3Pay/ic-reactor/blob/70bedf3c8779611a3b35710510442dee7f630b87/packages/react/src/types.ts#L227)

Base result interface shared between createQuery and createSuspenseQuery.

## Template

**TError**

The error type

## Extended by

- [`QueryResult`](https://ic-reactor.b3pay.net/v3/libs/interfaces/queryresult/)
- [`SuspenseQueryResult`](https://ic-reactor.b3pay.net/v3/libs/interfaces/suspensequeryresult/)

## Type Parameters

### TQueryFnData

`TQueryFnData`

The raw data type

### TSelected

`TSelected` = `TQueryFnData`

The type after select transformation

### _TError

`_TError` = `Error`

## Properties

### fetch

> **fetch**: () => `Promise`\<`TSelected`\>

Defined in: [react/src/types.ts:233](https://github.com/B3Pay/ic-reactor/blob/70bedf3c8779611a3b35710510442dee7f630b87/packages/react/src/types.ts#L233)

Fetch data in loader (uses ensureQueryData for cache-first)

#### Returns

`Promise`\<`TSelected`\>

***

### prefetch

> **prefetch**: () => `Promise`\<`void`\>

Defined in: [react/src/types.ts:245](https://github.com/B3Pay/ic-reactor/blob/70bedf3c8779611a3b35710510442dee7f630b87/packages/react/src/types.ts#L245)

Eagerly prefetch data into the cache without blocking.
Useful for preloading data before navigating to a route.

Unlike `fetch()`, this returns a void promise so it can be fire-and-forget.

#### Returns

`Promise`\<`void`\>

#### Example

```ts
// In a route hover handler
button.addEventListener("mouseenter", () => userQuery.prefetch())
```

***

### invalidate

> **invalidate**: () => `Promise`\<`void`\>

Defined in: [react/src/types.ts:248](https://github.com/B3Pay/ic-reactor/blob/70bedf3c8779611a3b35710510442dee7f630b87/packages/react/src/types.ts#L248)

Invalidate the cache (refetches if query is active)

#### Returns

`Promise`\<`void`\>

***

### getQueryKey

> **getQueryKey**: () => readonly `unknown`[]

Defined in: [react/src/types.ts:251](https://github.com/B3Pay/ic-reactor/blob/70bedf3c8779611a3b35710510442dee7f630b87/packages/react/src/types.ts#L251)

Get query key (for advanced React Query usage)

#### Returns

readonly `unknown`[]

***

### getCacheData

> **getCacheData**: \{(): `TSelected` \| `undefined`; \<`TFinal`\>(`select`): `TFinal` \| `undefined`; \}

Defined in: [react/src/types.ts:268](https://github.com/B3Pay/ic-reactor/blob/70bedf3c8779611a3b35710510442dee7f630b87/packages/react/src/types.ts#L268)

Read data directly from cache without fetching.
Returns undefined if data is not in cache.

#### Call Signature

> (): `TSelected` \| `undefined`

##### Returns

`TSelected` \| `undefined`

#### Call Signature

> \<`TFinal`\>(`select`): `TFinal` \| `undefined`

##### Type Parameters

###### TFinal

`TFinal`

##### Parameters

###### select

(`data`) => `TFinal`

##### Returns

`TFinal` \| `undefined`

#### Template

**TFinal**

Type returned after optional select transformation

#### Param

**select**

Optional select function to transform cached data further

#### Returns

Cached data with select applied, or undefined if not in cache

#### Example

```ts
// Just get the cached data
const user = userQuery.getCacheData()

// With additional select transformation
const name = userQuery.getCacheData((user) => user.name)
```

***

### setData

> **setData**: (`updater`) => `TQueryFnData` \| `undefined`

Defined in: [react/src/types.ts:287](https://github.com/B3Pay/ic-reactor/blob/70bedf3c8779611a3b35710510442dee7f630b87/packages/react/src/types.ts#L287)

Write raw data directly into the cache (useful for optimistic updates).
Accepts a new value or an updater function that receives the current cached raw data.

Note: The value is stored as raw (pre-select) data.  Any active `select`
transformations are automatically re-applied by React Query on the next render.

#### Parameters

##### updater

`TQueryFnData` \| ((`old`) => `TQueryFnData` \| `undefined`)

#### Returns

`TQueryFnData` \| `undefined`

#### Example

```ts
// Optimistic update before a mutation
userQuery.setData({ id: "1", name: "Alice" })

// Functional update
counterQuery.setData((prev) => (prev ?? 0) + 1)
```