Skip to content

W4101: derived() is not pure ​

Cause ​

derived() should compute a value from other signals without side effects, and this one writes a signal or calls something impure.

Example ​

xml
<contract>
{ "name": "Card", "role": "group", "parts": ["root"] }
</contract>
<script>
const a = state(0)
const b = state(0)
const d = derived(() => {
  b.value = 1
  return a.value
})
</script>
<template><div class="root">{d}</div></template>

What you see ​

text
WARNING  W4101  app/components/Card.tess:8:3
  derived() should be pure, but it assigns b.value. Move side effects into effect().
  Run `tessera explain W4101` for details.

Fix ​

Move the side effect into effect().

All errors and warnings