MCPcopy Create free account
hub / github.com/wavetermdev/waveterm / UseRef

Function UseRef

pkg/vdom/vdom.go:399–410  ·  view source on GitHub ↗
(ctx context.Context, val T)

Source from the content-addressed store, hash-verified

397}
398
399func UseRef[T any](ctx context.Context, val T) *VDomSimpleRef[T] {
400 _, hookVal := getHookFromCtx(ctx)
401 if !hookVal.Init {
402 hookVal.Init = true
403 hookVal.Val = &VDomSimpleRef[T]{Current: val}
404 }
405 refVal, ok := hookVal.Val.(*VDomSimpleRef[T])
406 if !ok {
407 panic("UseRef hook value is not a ref (possible out of order or conditional hooks)")
408 }
409 return refVal
410}
411
412func UseId(ctx context.Context) string {
413 vc := getRenderContext(ctx)

Callers

nothing calls this directly

Calls 1

getHookFromCtxFunction · 0.85

Tested by

no test coverage detected