@lynx-js/react / 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 Parameter |
|---|
T |
| Parameter | Type | Description |
|---|---|---|
initValue | T | The init value of the MainThreadRef. |
@lynx-js/react/runtime/lib/worklet/ref/workletRef.d.ts:55
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 Parameter |
|---|
T |
| Parameter | Type | Description |
|---|---|---|
initValue | T | The init value of the MainThreadRef. |
RefObject<T>
@lynx-js/react/runtime/lib/worklet/ref/workletRef.d.ts:94
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 Parameter | Default type |
|---|---|
T | undefined |
MainThreadRef<T | undefined>
@lynx-js/react/runtime/lib/worklet/ref/workletRef.d.ts:131