Skip to content

E0337: A hook found by its name ​

A live page's hooks are declared where they are written, with an attribute on the method: @ui.Mount, @ui.OnChange, @ui.Loads("group"). A method is never a hook because of its name. A method named Mount or Changed — the names earlier releases found the mount and change hooks by — that no attribute marks is refused, so a 1.x hook can't quietly become an exported method the browser calls. Mark it, or rename it if it is meant to be an event. A deferred group's loader named Load<Group> is the same mistake, reported as E0324.

vuka fix hooks adds the attributes. Reported by the compiler, by vukavet, and at start-up.

Wrong ​

html
<!-- pages/index.vuka.html -->
<script lang="go">
package pages

type Index struct {
	ui.Live
	rows []Row
}

func (p *Index) Mount(ctx context.Context) error {
	p.rows = load()
	return nil
}
</script>

<ul>…</ul>
html
<!-- pages/index.vuka.html -->
<script lang="go">
package pages

type Index struct {
	ui.Live
	rows []Row
}

@ui.Mount
func (p *Index) mount(ctx context.Context) error {
	p.rows = load()
	return nil
}
</script>

<ul>…</ul>

Released under the MIT License. Vuka builds on Go and its tools, which are made by the Go Authors. Vuka is not affiliated with Google or the Go project. Go is a trademark of Google LLC.