| 383 | } |
| 384 | |
| 385 | func UseVDomRef(ctx context.Context) *VDomRef { |
| 386 | vc, hookVal := getHookFromCtx(ctx) |
| 387 | if !hookVal.Init { |
| 388 | hookVal.Init = true |
| 389 | refId := vc.Comp.WaveId + ":" + strconv.Itoa(hookVal.Idx) |
| 390 | hookVal.Val = &VDomRef{Type: ObjectType_Ref, RefId: refId} |
| 391 | } |
| 392 | refVal, ok := hookVal.Val.(*VDomRef) |
| 393 | if !ok { |
| 394 | panic("UseRef hook value is not a ref (possible out of order or conditional hooks)") |
| 395 | } |
| 396 | return refVal |
| 397 | } |
| 398 | |
| 399 | func UseRef[T any](ctx context.Context, val T) *VDomSimpleRef[T] { |
| 400 | _, hookVal := getHookFromCtx(ctx) |