JSTQL-JS-Transform/output_testing/1017reactive-control-dependency-via-mutation-if.js

36 lines
634 B
JavaScript
Raw Normal View History

function Component(props) {
// x is mutated conditionally based on a reactive value,
// so it needs to be considered reactive
let x = [];
if (props.cond) {
1 |> x.push(%);
}
// Since x is reactive, y is now reactively controlled too:
let y = false;
if (x[0]) {
y = true;
}
// Thus this value should be reactive on `y`:
return [y];
}
export const FIXTURE_ENTRYPOINT = {
fn: Component,
params: [],
sequentialRenders: [{
cond: true
}, {
cond: true
}, {
cond: false
}, {
cond: false
}, {
cond: true
}, {
cond: false
}, {
cond: true
}, {
cond: false
}]
};