C07
Error
Components
C07 — A drag or a gesture on a component with no one element
drag:, dragGroup:, dropValue:, dropAxis:, dropInside:, on receive(d), on dragmove(d), on longpress and on swipe written on your component's call belong to the one element it draws. A component whose body is an if, a for, a show, a match or several elements has none to give them, so wrap what it draws in one element, or write them inside it.
What the compiler said
error[C07]: `drag:` on `Rows2` has no element to land on: its body is a `for` --> src/App.wf:6:16 | 6 | Rows2("a", drag: "a") | ^^^^ = help: Wrap what `Rows2` draws in one element (a `Stack`, a `Row`), or write `drag:` inside it = docs: https://webfluent.monzeromer.dev/errors/C07
The fix
Broken
component Rows2(_ name: String) {
for x in [1, 2] { Text(name) }
}
page P(path: "/", title: "T", description: "D") {
Heading("Files").h1
Rows2("a", drag: "a")
}
Fixed
component Rows2(_ name: String) {
Stack { for x in [1, 2] { Text(name) } }
}
page P(path: "/", title: "T", description: "D") {
Heading("Files").h1
Rows2("a", drag: "a")
}
Wrap what the component draws in one element — a Stack, a Row
— or write the drag inside it, on the element it is for.
Each example is a whole program: it is all of src/App.wf in a project with no other .wf file (trying an example).
Why this rule exists
drag:, dragGroup:, dropValue:, dropAxis:, dropInside: and the
handlers of the gestures — on receive(d), on dragmove(d), on
longpress, on swipe — written on your component's call belong to the one
element it draws. A body that is an if, a for, a show, a match or
several elements has no one element to give them.
lints cannot lower it: it would ship a broken page.