MCPcopy Index your code
hub / github.com/wavetermdev/waveterm / renderComponent

Method renderComponent

pkg/vdom/vdom_root.go:407–433  ·  view source on GitHub ↗
(cfunc any, elem *VDomElem, comp **ComponentImpl)

Source from the content-addressed store, hash-verified

405}
406
407func (r *RootElem) renderComponent(cfunc any, elem *VDomElem, comp **ComponentImpl) {
408 if (*comp).Children != nil {
409 for _, child := range (*comp).Children {
410 r.unmount(&child)
411 }
412 (*comp).Children = nil
413 }
414 props := make(map[string]any)
415 for k, v := range elem.Props {
416 props[k] = v
417 }
418 props[ChildrenPropKey] = elem.Children
419 ctx := r.makeRenderContext(*comp)
420 renderedElem := callCFunc(cfunc, ctx, props)
421 rtnElemArr := partToElems(renderedElem)
422 if len(rtnElemArr) == 0 {
423 r.unmount(&(*comp).Comp)
424 return
425 }
426 var rtnElem *VDomElem
427 if len(rtnElemArr) == 1 {
428 rtnElem = &rtnElemArr[0]
429 } else {
430 rtnElem = &VDomElem{Tag: FragmentTag, Children: rtnElemArr}
431 }
432 r.render(rtnElem, &(*comp).Comp)
433}
434
435func (r *RootElem) UpdateRef(updateRef VDomRefUpdate) {
436 refId := updateRef.RefId

Callers 1

renderMethod · 0.95

Calls 5

unmountMethod · 0.95
makeRenderContextMethod · 0.95
renderMethod · 0.95
partToElemsFunction · 0.85
callCFuncFunction · 0.70

Tested by

no test coverage detected