Closed
Description
Describe the bug
Minor, but given a component like this...
<script>
let a = $state(1);
let b = $state(2);
</script>
<p>{a} + {b} = {a + b}</p>
...neither a
nor b
is turned into state, because they are never updated. But the contents of the <p>
are put in an effect anyway:
export default function App($$anchor) {
let a = 1;
let b = 2;
var p = root();
+ var text = $.child(p);
- p.textContent = `${a ?? ""} + ${b ?? ""} = ${a + b ?? ""}`;
+ $.reset(p);
+ $.template_effect(() => $.set_text(text, `${a ?? ""} + ${b ?? ""} = ${a + b ?? ""}`));
$.append($$anchor, p);
}
Whatever logic is used for determining whether it's a = 1
or a = $.state(1)
should also be used for determining whether to create an effect.
Reproduction
Logs
No response
System Info
next
Severity
annoyance
Metadata
Metadata
Assignees
Labels
No labels