1.4 KiB
1.4 KiB
Input
function Component(props) {
let x;
switch (props.cond) {
case true: {
x = 1;
break;
}
case false: {
x = 2;
break;
}
default: {
x = 3;
}
}
// The values assigned to `x` are non-reactive, but the value of `x`
// depends on the "control" value `props.cond` which is reactive.
// Therefore x should be treated as reactive too.
return [x];
}
export const FIXTURE_ENTRYPOINT = {
fn: Component,
params: [],
sequentialRenders: [
{cond: true},
{cond: true},
{cond: false},
{cond: false},
{cond: true},
{cond: false},
{cond: true},
{cond: false},
],
};
Code
import { c as _c } from "react/compiler-runtime";
function Component(props) {
const $ = _c(2);
let x;
bb0: switch (props.cond) {
case true: {
x = 1;
break bb0;
}
case false: {
x = 2;
break bb0;
}
default: {
x = 3;
}
}
let t0;
if ($[0] !== x) {
t0 = [x];
$[0] = x;
$[1] = t0;
} else {
t0 = $[1];
}
return t0;
}
export const FIXTURE_ENTRYPOINT = {
fn: Component,
params: [],
sequentialRenders: [
{ cond: true },
{ cond: true },
{ cond: false },
{ cond: false },
{ cond: true },
{ cond: false },
{ cond: true },
{ cond: false },
],
};
Eval output
(kind: ok) [1] [1] [2] [2] [1] [2] [1] [2]