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/Class.MainThreadRef.md.
  • 简体中文
  • @lynx-js/react / MainThreadRef

    类: MainThreadRef<T>

    A MainThreadRef is a ref that can only be accessed on the main thread. It is used to preserve states between main thread function calls. The data saved in current property of the MainThreadRef can be read and written in multiple main thread functions.

    继承

    • WorkletRef<T>

    类型参数

    类型参数
    T

    构造函数

    new MainThreadRef()

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

    参数

    范围类型
    initValueT

    返回

    MainThreadRef<T>

    重写了

    WorkletRef<T>.constructor

    定义于

    @lynx-js/react/runtime/lib/snapshot/worklet/ref/workletRef.d.ts:15

    访问器

    current

    Getter 签名

    get current(): T
    返回

    T

    Setter 签名

    set current(_: T): void
    参数
    范围类型
    _T
    返回

    void

    继承自

    WorkletRef.current

    定义于

    @lynx-js/react/runtime/lib/snapshot/worklet/ref/workletRef.d.ts:4

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