P03
Warning
What is kept in the browser
P03 — A persisted value in a route-scoped store
The route change drops the store, and the next read builds it again from storage, so the value comes straight back.
What the compiler said
warning[P03]: `search` is persisted in a store scoped to the route --> src/App.wf:2:5 | 2 | persist search = "" | ^^^^^^^ = help: The route change drops the store and the next read builds it again from storage, so the value comes straight back. Use `state` for what the route owns, or widen the scope for what outlives it = docs: https://webfluent.monzeromer.dev/errors/P03
The fix
Broken
store Filters(scope: .route) {
persist search = ""
}
Fixed
store Filters(scope: .route) {
state search = ""
}
page P(path: "/", title: "T", description: "D") {
use Filters
Heading("Search").h1
Input(bind: Filters.search, label: "Search")
}
Keep route-scoped data in state, or move the value to a store with a wider scope.
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": { "P03": "off" }
// wf-allow(P03)