Your component runs once. Ever.
Delete useMemo. Delete useCallback. Delete every dependency array. A Pyreon component runs when it mounts, and a signal change updates the one DOM node that shows it, so there is nothing left to memoise.
npm create @pyreon/zero@latest Skipping the work shows up on the clock.
- 2.7× faster than React 19 at creating 10,000 rows (73.1 ms vs 195.9 ms)final pass, two runs · Apple M3 Max · real Chromium · synthetic, author-run
- 2.4× faster than React 19 at toggling 1,000 todos in a TodoMVC-shaped app (4.60 ms vs 11.41 ms)overnight run, one run · Apple M3 Max · synthetic, author-run
- 2.0–2.1× faster effect propagation than Preact Signals (1,407 vs 2,874 ns, V8)final pass, two runs · Node (V8) · Apple M3 Max · synthetic, author-run
Also from the same record: clearing 1,000 todos runs 3–4× faster than React 19 (one run), and the reactivity core beats Preact Signals on batching (1.94–1.95×) and the computed diamond (1.30–1.31×) on V8, two runs. Reproduce any of it from /benchmarks.
Every result, including where we lose →The code you delete.
import { memo, useCallback, useMemo, useState } from 'react'
const Controls = memo(function Controls({ onAdd }: { onAdd: () => void }) {
return <button onClick={onAdd}>+1</button>
})
export function Counter() {
const [count, setCount] = useState(0)
const [log, setLog] = useState<{ id: number; at: number }[]>([])
const doubled = useMemo(() => count * 2, [count])
const add = useCallback(() => {
setCount((c) => c + 1)
setLog((l) => [...l, { id: l.length, at: Date.now() }])
}, [])
return (
<div>
<Controls onAdd={add} />
<p>{count} × 2 = {doubled}</p>
{count > 9 && <p>Double digits.</p>}
<ul>
{log.map((e) => (
<li key={e.id}>{new Date(e.at).toLocaleTimeString()}</li>
))}
</ul>
</div>
)
}import { signal, computed } from '@pyreon/reactivity'
import { For, Show } from '@pyreon/core'
function Controls(props: { onAdd: () => void }) {
return <button onClick={props.onAdd}>+1</button>
}
export function Counter() {
const count = signal(0)
const log = signal<{ id: number; at: number }[]>([])
const doubled = computed(() => count() * 2)
const add = () => {
count.update((c) => c + 1)
log.update((l) => [...l, { id: l.length, at: Date.now() }])
}
return (
<div>
<Controls onAdd={add} />
<p>{count()} × 2 = {doubled()}</p>
<Show when={() => count() > 9}>
<p>Double digits.</p>
</Show>
<ul>
<For each={log()} by={(e) => e.id}>
{(e) => <li>{new Date(e.at).toLocaleTimeString()}</li>}
</For>
</ul>
</div>
)
}Same counter, same derived value, same list. On the left, memo, useMemo and useCallback exist only to tell React what not to redo. On the right, add is a plain function created once, computed tracks its own dependencies, and <For> keys rows with by. No dependency array anywhere, because a signal records who read it.
Zero re-renders, by construction.
In React the counter body runs on every click. It builds a new element tree and the reconciler diffs it against the old one to find a single changed character. That is why useMemo, useCallback, memo and dependency arrays exist: every value in the body is recreated on each render, so you have to say which ones are stable.
In Pyreon the body runs once, at mount. A handler defined in the body is created once. A computed() is created once and tracks what it reads. When count changes, count notifies the text node bound to it, and nothing else in the tree is visited.
You lose the afternoon you used to spend on "why did this re-render?". There is no second render to ask about.
Ten lines in, one binding out.
This is what transformJSX from @pyreon/compiler emits for a counter. The static markup becomes a cached template string. The only dynamic part is one line: _bindText(count, __t2) subscribes that text node straight to the signal. Clicking + writes one text node, and that is the whole update.
import { signal } from '@pyreon/reactivity'
function Counter() {
const count = signal(0)
return (
<div>
<button onClick={() => count.update((n) => n - 1)}>-</button>
<span>{count()}</span>
<button onClick={() => count.update((n) => n + 1)}>+</button>
</div>
)
}import { _tpl, _bindText } from "@pyreon/runtime-dom";
import { signal } from '@pyreon/reactivity'
function Counter() {
const count = signal(0)
return _tpl("<div><button>-</button><span> </span><button>+</button></div>", (__root) => {
const __e0 = __root.firstElementChild;
const __e1 = __e0.nextElementSibling;
const __t2 = __e1.firstChild;
const __e3 = __e1.nextElementSibling;
__e0.__ev_click = () => count.update((n) => n - 1);
const __d0 = _bindText(count, __t2);
__e3.__ev_click = () => count.update((n) => n + 1);
return __d0
})
}Unedited compiler output apart from indentation and the parentheses around the returned template. Paste any component into transformJSX and read what comes back.
Click it. Count the renders.
A real Pyreon counter, running in this page. The numbers come from the component and the DOM, not from a script.
- count0
- Counter() body ran0
- text-node writes0
- elements created after mount0
Measured in this page: a counter in the component body, and a MutationObserver on the DOM.
count.update(n => n + 1) writes one text node. The body above ran once.
What replaces what.
- state
const [n, setN] = useState(0)const n = signal(0) - derived value
useMemo(() => n * 2, [n])computed(() => n() * 2) - stable handler
useCallback(fn, [deps])a plain function - skip a child render
memo(Child)nothing: children never re-render - update
setN((n) => n + 1)n.update((v) => v + 1) - keyed list
items.map((i) => <li key={i.id}>…)<For each={items()} by={(i) => i.id}> - conditional
{cond && <p/>}<Show when={() => cond()}>
Watch it happen in your own app.
Open the reactive overlay
Press
Ctrl+Shift+Rin any dev build (or call$p.reactivity()in the console). It is built into@pyreon/runtime-domand tree-shaken from production builds, so there is nothing to install.Read the Health and Activity tabs
Health lists orphan signals, high fan-out and deep chains. Activity shows the latest updates with the chain of writes that caused each one.
Press Pick, then click a value
In the Inspect tab, press Pick (or call
$p.pick()) and click text bound to a single signal or computed. The panel shows that signal and its change chain. Text built from several signals shows nothing, by design: the link is recorded exactly when the binding is made, never guessed.
Live or static, decided before you run anything.
The Reactivity Lens prints the compiler's own verdict next to every JSX expression in your editor, served by pyreon-lint --lsp.
live
Reads a signal in a tracked position. It updates.
live·prop
A reactive component prop, wired as a getter on props.
live·attr
An attribute that re-evaluates when its signals change.
static
Evaluated once. If you expected live, you just found the bug.
hoisted
A provably static subtree lifted to module scope.
Signal reads inside reactive scopes re-evaluate when the signal changes. Signal reads outside reactive scopes evaluate once and become static.
The rules, straight.
Run-once has a small set of rules. They are what the compiler emits, and the lint rules and the Lens catch the common slips.
Destructuring props captures once
const { name } = props copies the value at setup, so the text never changes. Read props.name, or use splitProps(props, ['name']), whose pieces keep their getters.
A const derived from props stays live
const name = props.name ?? 'stranger' is inlined at its JSX use site and re-reads props.name. A let is never inlined.
An early return runs once
if (loading()) return <Skeleton /> pins the component to whichever branch was true at mount. Use <Show when={loading()} fallback={…}>, or return an accessor.
Write with .set(), not a call
count(5) is a read that ignores its argument. count.set(5) and count.update(fn) write.
Prefer plain JavaScript? Opt in to Plain Mode
Plain Mode is an opt-in compile-time dialect: 'use plain' at the top of a file (or pyreon({ plain: true }) app-wide) lets you write let count = state(0); count++. Destructured props stay live and early returns on a reactive condition become reactive. It compiles to the same signal code.
'use plain'
import { state, derived } from '@pyreon/core/plain'
let count = state(0)
const double = derived(count * 2)
export function Counter({ label, step = 1 }: { label: string; step?: number }) {
return <button onClick={() => { count += step }}>{label}: {count} / {double}</button>
}We publish where we lose, so you can trust where we win: in the same record a mounted 2,047-component tree holds about 2.6× the memory it takes in Solid 1.9, creating a signal is about 5× slower than in Preact Signals, and the same keyed-table app is 18.5 KB gzip against Solid's 7.7 KB.
source →Questions a React developer asks.
Is this just Solid?
Same run-once model, and we are happy to say so. The compiler does more of the wiring: a bare signal read binds the signal itself with no closure, signal reads in component props become getters, and a const derived from props is inlined so it stays reactive.
Can hooks be conditional?
Yes. React identifies hooks by call order across renders. Pyreon has no second render, so a hook is an ordinary call made during setup. What you cannot do is call one after setup: inside a click handler, a setTimeout or after an await.
What about a list?
<For each={items()} by={(i) => i.id}>. The key prop is by, because JSX reserves key. Each row's bindings are separate, so toggling one todo touches one attribute on one <li>, and reordering moves existing nodes by key.
How do I know a value is live?
Look at the Lens hint in your editor. It is the compiler's own live or static verdict for that expression, so it shows what the build will do. pyreon check catches the common slips, such as destructured props, before you commit.
The best re-render is the one that never happens.
npm create @pyreon/zero@latest