Error codesState

state() is created inside a branch, loop or handler

MARKLESS_STATE_CREATION_SITE_UNSTABLEerrorMarkless raises it while it builds your .tsrx files.

The message

MARKLESS_STATE_CREATION_SITE_UNSTABLE: <apiName>() creates "<name>" <message>. That would ship a graph cell whose identity does not match when this code runs.
<why> Graph cells are planned into the payload before rendering, so each authored declaration needs one stable component-body or shared owner.
https://markless.dev/errors/MARKLESS_STATE_CREATION_SITE_UNSTABLE

Words in angle brackets change from case to case.

Why

Each state() and computed() needs one fixed place in the component. This one sits inside a loop, an event handler, another computed(), or an @if/@switch arm with a starting value the compiler cannot read. A state() in an arm is allowed when its starting value is a literal: it starts fresh each time the arm opens.

Fix

Give the arm state a literal starting value, such as state(0) or state(""), or declare the value once at the top level of the component body and branch around the markup that uses it. Write to it from the handler instead of creating it there.

Where Markless raises it

All error codes