Skip to content
These are temporary community docs. The official docs are in progress.Help improve them
Markless
Esc
↑↓navigate↵open⌘Jpreview
On this page

MARKLESS_STATE_WRITE_IN_COMPUTED

A computed() body writes to state.

Error from the compiler, while it builds your .tsrx files.

What happened

A computed() reads values and returns a result. This one also writes to state, and that write wakes the same computed again.

Markless prints the message, the reason, and a suggestion:

MARKLESS_STATE_WRITE_IN_COMPUTED: `<source>` writes to `<target>` while deriving a computed value. A computed is a graph read, so writing graph state there would re-trigger the same derivation.
A computed is a demand-driven read in the graph; the only effects in the system are compiler-generated DOM updates, so a write inside a derive is a self-waking cycle that cannot resume.
Keep computed() pure. Move graph writes to an event handler and derive only from graph reads.
https://markless.dev/errors/MARKLESS_STATE_WRITE_IN_COMPUTED

Words in angle brackets change from case to case.

How to fix it

Keep computed() free of writes. Move the write into an event handler.

Where it comes from

@markless/compiler raises this code. Source:

Read how to read a Markless error, or go back to all error codes.

Was this page helpful?