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

Function DefineComponent

pkg/waveapp/waveapp.go:261–275  ·  view source on GitHub ↗
(client *Client, name string, renderFn func(ctx context.Context, props P) any)

Source from the content-addressed store, hash-verified

259}
260
261func DefineComponent[P any](client *Client, name string, renderFn func(ctx context.Context, props P) any) vdom.Component[P] {
262 if name == "" {
263 panic("Component name cannot be empty")
264 }
265 if !unicode.IsUpper(rune(name[0])) {
266 panic("Component name must start with an uppercase letter")
267 }
268 err := client.RegisterComponent(name, renderFn)
269 if err != nil {
270 panic(err)
271 }
272 return func(props P) *vdom.VDomElem {
273 return vdom.E(name, vdom.Props(props))
274 }
275}
276
277func (c *Client) RegisterComponent(name string, cfunc any) error {
278 return c.Root.RegisterComponent(name, cfunc)

Callers

nothing calls this directly

Calls 3

EFunction · 0.92
PropsFunction · 0.92
RegisterComponentMethod · 0.45

Tested by

no test coverage detected