函数: useMainThreadRef()
调用签名
useMainThreadRef<
T>(initValue:T):MainThreadRef<T>
Create A MainThreadRef.
MainThreadRef 是一种只能在主线程访问的 ref,用于在主线程函数调用之间保存状态。保存在 MainThreadRef 的 current 属性中的数据,可以在多个主线程函数中读写。
它是一个 Hook,只应在组件的顶层调用。
类型参数
参数
返回
示例
调用签名
useMainThreadRef<
T>(initValue:T|null):RefObject<T>
Create A MainThreadRef.
MainThreadRef 是一种只能在主线程访问的 ref,用于在主线程函数调用之间保存状态。保存在 MainThreadRef 的 current 属性中的数据,可以在多个主线程函数中读写。
它是一个 Hook,只应在组件的顶层调用。
类型参数
参数
返回
RefObject<T>
示例
调用签名
useMainThreadRef<
T=undefined>():MainThreadRef<T|undefined>
Create A MainThreadRef.
MainThreadRef 是一种只能在主线程访问的 ref,用于在主线程函数调用之间保存状态。保存在 MainThreadRef 的 current 属性中的数据,可以在多个主线程函数中读写。
它是一个 Hook,只应在组件的顶层调用。
类型参数
返回
MainThreadRef<T | undefined>