A handler changes a plain variable the page shows
The message
MARKLESS_STATE_STALE_LOCAL_WRITE: Cannot write to "<target>" from a handler because the template reads the component local "<name>" only during initial render.
Component bodies run for initial render only. Template reads re-render after events only when they subscribe through state(), so this handler write would leave the UI stale after resume.
Move "<name>" into state(), then write <name>++ so Markless can serialize the cell and update subscribed DOM.
https://markless.dev/errors/MARKLESS_STATE_STALE_LOCAL_WRITEWords in angle brackets change from case to case.
Why
A handler changes a plain let, and the markup shows that variable. The markup reads it only once, when the page first renders, so the click changes nothing on screen.
Fix
Wrap the value in state(). Then the page updates every time the handler writes it.
Before
export function Settings() @{ let theme = 'light'; <button onClick={() => (theme = 'dark')}>Theme: {theme}</button>}After
let theme = state('light');<button onClick={() => (theme = 'dark')}>Theme: {theme}</button>