Reactive composition repro
Counter: {counter}
Tick
{
/* Baseline reference: this ALWAYS renders. If we see this and the
page is otherwise blank, the variants are the cause. */
}
Baseline (always rendered)
If you see this line, JSX is rendering. If not, the pattern crashed.
{/* W1: style={computed(...)} returning an object */}
W1 — style={computed(…)} → object
{ENABLE_W1_STYLE_COMPUTED_OBJECT
? (
({
padding: "8px",
background: (counter ?? 0) % 2 === 0 ? "#dbeafe" : "#fde68a",
borderRadius: "4px",
}))}
>
W1 content; bg toggles every tick.
)
: (
W1 disabled (ENABLE_W1_STYLE_COMPUTED_OBJECT = false)
)}
{/* W2: style={computed(...)} returning a string */}
W2 — style={computed(…)} → string
{ENABLE_W2_STYLE_COMPUTED_STRING
? (
`padding: 8px; background: ${
(counter ?? 0) % 2 === 0 ? "#dbeafe" : "#fde68a"
}; border-radius: 4px;`
)}
>
W2 content; bg toggles every tick.
)
: (
W2 disabled (ENABLE_W2_STYLE_COMPUTED_STRING = false)
)}
{/* W3: many top-level computed-VNode blocks */}
W3 — multiple computed-VNode blocks
{ENABLE_W3_MULTIPLE_COMPUTED_VNODES
? (
{computed(() => (
Block A — counter is{" "}
{(counter ?? 0) > 0 ? "positive" : "zero"}
))}
{computed(() => (
Block B — counter mod 2 is{" "}
{(counter ?? 0) % 2}
))}
{computed(() => (
Block C — counter squared is{" "}
{(counter ?? 0) * (counter ?? 0)}
))}
{computed(() => (
Block D — counter == 5? {(counter ?? 0) === 5 ? "yes" : "no"}
))}
)
: (
W3 disabled (ENABLE_W3_MULTIPLE_COMPUTED_VNODES = false)
)}
{/* W4: cf-input $value= inside a computed block */}
W4 — cf-input $value= inside computed
{ENABLE_W4_CF_INPUT_INSIDE_COMPUTED
? (
{computed(() => (
Expect "$value not reactive" runtime error:
))}
)
: (
W4 disabled (ENABLE_W4_CF_INPUT_INSIDE_COMPUTED = false)
)}
),
counter: counter ?? 0,
tick: boundTick,
};
});