@lynx-js/react / useMainThreadRef
函数: useMainThreadRef()
useMainThreadRef(initValue)
Create A MainThreadRef.
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.
It is a hook and it should only be called at the top level of your component.
类型参数
参数
返回
示例
定义于
@lynx-js/react/runtime/lib/snapshot/worklet/ref/workletRef.d.ts:55
useMainThreadRef(initValue)
Create A MainThreadRef.
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.
It is a hook and it should only be called at the top level of your component.
类型参数
参数
返回
RefObject<T>
示例
定义于
@lynx-js/react/runtime/lib/snapshot/worklet/ref/workletRef.d.ts:94
useMainThreadRef()
Create A MainThreadRef.
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.
It is a hook and it should only be called at the top level of your component.
类型参数
返回
MainThreadRef<T | undefined>
示例
定义于
@lynx-js/react/runtime/lib/snapshot/worklet/ref/workletRef.d.ts:131