@lynx-js/react / useMainThreadRef
Function: 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.
Type Parameters
Parameters
Returns
Example
Defined in
@lynx-js/react/runtime/lib/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.
Type Parameters
Parameters
Returns
RefObject<T>
Example
Defined in
@lynx-js/react/runtime/lib/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.
Type Parameters
Returns
MainThreadRef<T | undefined>
Example
Defined in
@lynx-js/react/runtime/lib/worklet/ref/workletRef.d.ts:131