Skip to content
Gx
GitHub

GX2015: component with signals has no top-level HTML element

A component has signals, and its markup has no HTML element at the top level.

Cause

A component has signals, and its markup has no HTML element at the top level. Gx writes the first values of the signals on the first top-level HTML element. A component tag at the top level does not take them.

Example

cart/Card.gx
package cart

props {
  Children gx.Node
}

<article>{p.Children}</article>
cart/Panel.gx
package cart

signals {
  Open bool = false
}

<Card>
  <button on:click={$Open = !$Open}>Details</button>
  <p show={$Open}>The details.</p>
</Card>

gx check reports:

gx check
cart/Panel.gx:3:1: GX2015: a component with signals needs a top-level HTML element to hold their first values

Fix

Put the markup of the component inside one HTML element, for example <div>.