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, and this page is available as Markdown at /next/zh/api/react/Types/MainThreadRef.md.
  • 简体中文
  • 类: MainThreadRef<T>

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

    类型参数

    类型参数
    T

    构造函数

    构造函数

    new MainThreadRef<T>(initValue: T): MainThreadRef<T>

    参数

    参数类型
    initValueT

    返回

    MainThreadRef<T>

    访问器

    current

    Getter 签名

    get current(): T

    返回

    T

    Setter 签名

    set current(_: T): void

    参数
    参数类型
    _T
    返回

    void

    除非另有说明,本项目采用知识共享署名 4.0 国际许可协议进行许可,代码示例采用 Apache License 2.0 许可协议进行许可。