E114
Error
Syntax and structure
E114 — emit outside a component
An event belongs to a component, which declares it and fires it with emit; a page has none.
What the compiler said
error[E114]: `emit` fires a component's event; a page has none --> src/App.wf:3:33 | 3 | Button("Save") { on click { emit saved() } } | ^^^^ = docs: https://webfluent.monzeromer.dev/errors/E114
The fix
Broken
page P(path: "/", title: "T", description: "D") {
Heading("Save").h1
Button("Save") { on click { emit saved() } }
}
Fixed
page P(path: "/", title: "T", description: "D") {
state saves = 0
action save() { saves = saves + 1 }
Heading("Saved {saves} times").h1
Button("Save") { on click { save() } }
}
Fire the event from the component that declares it; a page calls an action instead.
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 cannot lower it: it would ship a broken page.