Skip to content

E0149: A state written where nothing sends it to the page ​

A ui.State is the browser's: a write is a command the page runs. It is written in an element's on… attribute, where the write is a chain of JS commands the browser runs at once, or in a method of a live component — a handler, a hook, an Update — where the compiler pushes the command with the reply (p.PushJS(p.tab.Set("env"))). Written anywhere else there is no page to send it to: while the markup renders, in a function that isn't a method, in a method of a static component.

Wrong ​

html
<!-- tabs.vuka.html -->
<script lang="go">
package app

type Tabs struct {
	tab ui.State[string]
}
</script>

<nav>
  tab = "env"
  <button>Env</button>
</nav>
html
<!-- tabs.vuka.html -->
<script lang="go">
package app

type Tabs struct {
	tab ui.State[string]
}
</script>

<nav>
  <button onClick={tab = "env"}>Env</button>
</nav>

A state's value before any write is its type's zero value; one that starts elsewhere is set in a live component's @ui.Mount.

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.