MCPcopy
hub / github.com/wavetermdev/waveterm / DefineComponentEx

Function DefineComponentEx

tsunami/engine/clientimpl.go:332–346  ·  view source on GitHub ↗
(client *ClientImpl, name string, renderFn func(props P) any)

Source from the content-addressed store, hash-verified

330}
331
332func DefineComponentEx[P any](client *ClientImpl, name string, renderFn func(props P) any) vdom.Component[P] {
333 if name == "" {
334 panic("Component name cannot be empty")
335 }
336 if !unicode.IsUpper(rune(name[0])) {
337 panic("Component name must start with an uppercase letter")
338 }
339 err := client.registerComponent(name, renderFn)
340 if err != nil {
341 panic(err)
342 }
343 return func(props P) *vdom.VDomElem {
344 return vdom.H(name, structToProps(props))
345 }
346}
347
348func (c *ClientImpl) registerComponent(name string, cfunc any) error {
349 return c.Root.RegisterComponent(name, cfunc)

Callers 1

DefineComponentFunction · 0.92

Calls 3

HFunction · 0.92
structToPropsFunction · 0.85
registerComponentMethod · 0.80

Tested by

no test coverage detected