V12

Warning

Vocabulary

V12 — A long list that is not windowed

A VirtualList draws only the rows in view of one keyed for — for row in rows by row.id { … } — that is the whole of its body; with anything else in it, or a for with no by, it draws everything, as a plain scrolling box does.

What the compiler said

warning[V12]: This `VirtualList` draws every row: its body is not one keyed `for` --> src/App.wf:4:5 | 4 | VirtualList(rowHeight: 32) { | ^^^^^^^^^^^ = help: Make its body one `for` with a `by`: `VirtualList(rowHeight: 32) { for row in rows by row.id { … } }` = docs: https://webfluent.monzeromer.dev/errors/V12

The fix

Broken

wf

page P(path: "/", title: "T", description: "D") { state rows = ["a", "b"] Heading("Files").h1 VirtualList(rowHeight: 32) { for r in rows { Text(r) } } }

Fixed

wf

page P(path: "/", title: "T", description: "D") { state rows = ["a", "b"] Heading("Files").h1 VirtualList(rowHeight: 32) { for r in rows by r { Text(r) } } }

Give the for a by, and move anything else — a heading, a count — outside the VirtualList.

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

A VirtualList draws only the rows in view of the one keyed for that is the whole of its body. With anything else beside the for, or a for with no by — which has no way to keep a row's nodes as it scrolls — it draws every row, as a plain scrolling box does, and the length of the list is what the page pays for.

lints may lower it:

"lints": { "V12": "off" } // wf-allow(V12)