(client *Client, name string, renderFn func(ctx context.Context, props P) any)
| 259 | } |
| 260 | |
| 261 | func 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 | |
| 277 | func (c *Client) RegisterComponent(name string, cfunc any) error { |
| 278 | return c.Root.RegisterComponent(name, cfunc) |
nothing calls this directly
no test coverage detected