> For AI agents: the complete documentation index is available at /next/zh/llms.txt, the full documentation bundle is available at /next/zh/llms-full.txt.

# Class: MainThreadRef\<T>

`MainThreadRef` 是一种只能在主线程访问的 ref，用于在主线程函数调用之间保存状态。保存在 `MainThreadRef` 的 `current` 属性中的数据，可以在多个主线程函数中读写。

## Type Parameters

| Type Parameter |
| -------------- |
| `T`            |

## Constructors

### Constructor

> **new MainThreadRef**\<`T`>(`initValue`: `T`): `MainThreadRef`\<`T`>

#### Parameters

| Parameter   | Type |
| ----------- | ---- |
| `initValue` | `T`  |

#### Returns

`MainThreadRef`\<`T`>

## Accessors

### current

#### Get Signature

> **get** **current**(): `T`

##### Returns

`T`

#### Set Signature

> **set** **current**(`_`: `T`): `void`

##### Parameters

| Parameter | Type |
| --------- | ---- |
| `_`       | `T`  |

##### Returns

`void`
