Skip to content

E0150: A write the browser can't run ​

An element's on… attribute holding statements is a chain of JS commands: each statement is a write of a ui.State — x = v with a value of the server's, x = !x for a bool, x++ or x-- for a number — or a call of a handler, which the chain pushes to the server after the writes before it. Anything else can't run in the browser: another assignment operator (x += 2), a value that reads a state (x = x + "!"), a write of a field that isn't a state, another statement.

Server state is written in a handler instead, and a tracked field (a .vuka.html struct's unexported one) is written through its own name, not a pointer to it: &p.rows would change it without the session seeing. Its fields and methods read through it (p.employer.Name), and a write into it (p.employer.Name = x, or a pointer method called as a statement, p.employer.Rename(x)) updates it; a pointer method called inside an expression (n := p.t.Inc() + 1) would change a copy, so it is this error too: call it as a statement of its own.

Wrong ​

html
<button onClick={count += 2}>+2</button>
<button onClick={label = label + "!"}>!</button>
html
<button onClick={count++; count++}>+2</button>
<button onClick={AddBang()}>!</button>

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.