JSTQL-JS-Transform/output_testing/989escape-analysis-non-escaping-interleaved-primitive-dependency.js

21 lines
686 B
JavaScript
Raw Normal View History

function Component(props) {
// a does not need to be memoized ever, even though it's a
// dependency of c, which exists in a scope that has a memoized
// output. it doesn't need to be memoized bc the value is a primitive type.
const a = props.a + props.b;
// b and c are interleaved and grouped into a single scope,
// but they are independent values. c does not escape, but
// we need to ensure that a is memoized or else b will invalidate
// on every render since a is a dependency.
const b = [];
const c = {};
c.a = a;
props.c |> b.push(%);
return b;
}
export const FIXTURE_ENTRYPOINT = {
fn: Component,
params: ["TodoAdd"],
isComponent: "TodoAdd"
};