GX2009: loop needs a key
A loop body holds an input, a component with signals or a transition, and it has no key.
Cause
A loop body holds an input, a component with signals or a transition, and it has no key. Without a key, an update can move state from one row to a different row.
Example
package cart
props {
Names []string
}
<ul>
for _, name := range p.Names {
<li><input value={name} /></li>
}
</ul>gx check reports:
cart/List.gx:8:3: GX2009: loop needs a key: add key={expr} or a #fragment with a key parameterFix
- Add
key={expr}to the first element of the loop body. Use a value that is unique for each row. - Or mark the element as a fragment with a
keyparameter.