Skip to content
Gx
GitHub

GX2007: dynamic event attribute

An HTML event attribute such as onclick has an expression as its value.

Cause

An HTML event attribute such as onclick has an expression as its value. A value from the server in a script is a risk.

Example

ui/card/Card.gx
package card

props {
  Script string
}

<button onclick={p.Script}>Run</button>

gx check reports:

gx check
ui/card/Card.gx:7:9: GX2007: attribute "onclick" cannot take an expression

Fix

Use an on: directive with a signal statement or an action, for example on:click={route.Add{}}.