E0130: A hook attribute that is no hook
A hook attribute on a method — @ui.Mount, @ui.OnChange, @ui.Loads("lists") — is a call of the page's LiveSchema, with the method as its last argument. Its arguments go in parentheses, and the method's type must be live: it embeds ui.Live (a .vuka.html shape declaring a hook gets it embedded). On any other type there is no LiveSchema for the hook to go into; it is reported rather than lowered as a call of a function of the same name, such as the islands' ui.Mount(props). Generic types take hooks like any other: the LiveSchema is a method of the generic type, one per instantiation.
Wrong
vuka
@ui.Loads{Group: "lists"}
func (d *Dashboard) loadLists(ctx context.Context) error { … }
type List[T any] struct{ Items []T }
@ui.Mount
func (l *List[T]) mount(ctx context.Context) error { … }Right
vuka
@ui.Loads("lists")
func (d *Dashboard) loadLists(ctx context.Context) error { … }
type List[T any] struct {
ui.Live
Items []T
}
@ui.Mount
func (l *List[T]) mount(ctx context.Context) error { … }