Diagnostics

LUM2002: Signal write during render

A signal is written while a component or computed is rendering.

Severity: error · Category: reactivity (2xxx)

Reported by: the compiler.

#What it means

Component setup and computeds run during render. Writing a signal there (count.set(…), items.push(…) on a store) re-triggers bindings mid-render, can loop, and makes the output depend on render order.

#Example

tsx
export function Profile(props: { name: string }) {
  const visits = signal(0);
  visits.set(visits.peek() + 1);
  return <p>{props.name}</p>;
}

#How to fix it

Initialize the signal with the value instead (signal(initial)), derive with computed, or write in an event handler, onMount or an effect.