X06

Warning

State and reactivity

X06 — A state that copies a live value once

now, viewport, query, hash, theme, network and update keep themselves current, but a state takes its initial value once: state clock = now(every: 1.seconds) holds the moment the page opened, and everything worked out from it stays there. A derived value follows what it reads. A state the program goes on to assign or bind starts from the live value on purpose, and draws nothing.

What the compiler said

warning[X06]: `clock` copies `now` once, when the page opens, and never follows it --> src/App.wf:3:5 | 3 | state clock = now(every: 1.seconds) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = help: Nothing assigns `clock`: declare it `derived`, which is worked out again whenever `now` changes = docs: https://webfluent.monzeromer.dev/errors/X06

Your editor offers this fix: Change to derived clock. wf fix --code X06 applies it to every place it fits.

The fix

Broken

wf

page P(path: "/", title: "T", description: "D") { state posted = @2026-03-14T09:30:00Z state clock = now(every: 1.seconds) derived age = posted.until(clock) Heading("Posted {age.minutes()} minutes ago").h1 }

Fixed

wf

page P(path: "/", title: "T", description: "D") { state posted = @2026-03-14T09:30:00Z derived clock = now(every: 1.seconds) derived age = posted.until(clock) Heading("Posted {age.minutes()} minutes ago").h1 }

Declare it derived — the quick fix does. derived clock = now(every: 1.seconds) is worked out again on every tick, and so is everything that reads it. now, viewport, query, hash, theme, network and update all keep themselves current; a state only takes the value it starts with. A state the program assigns, binds or changes in place is a starting value on purpose — state tab = query.tab ?? "all" that a click then changes — and draws nothing. Neither does a live value read inside a lambda, which reads it each time it is called.

Each example is a whole program: it is all of src/App.wf in a project with no other .wf file (trying an example).

lints may lower it:

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