aliased-nested-scope-fn-expr.tsx — react Source File
Architecture documentation for aliased-nested-scope-fn-expr.tsx, a tsx file in the react codebase. 1 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR 628390ea_abba_ee81_f26d_b104444da189["aliased-nested-scope-fn-expr.tsx"] 006eec3d_77a9_4a47_e6c1_a96d7a6c9c05["shared-runtime"] 628390ea_abba_ee81_f26d_b104444da189 --> 006eec3d_77a9_4a47_e6c1_a96d7a6c9c05 style 628390ea_abba_ee81_f26d_b104444da189 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
// @enableTransitivelyFreezeFunctionExpressions:false
import {
Stringify,
mutate,
identity,
setPropertyByKey,
shallowCopy,
} from 'shared-runtime';
/**
* Function expression version of `aliased-nested-scope-truncated-dep`.
*
* In this fixture, the output would be invalid if propagateScopeDeps did not
* avoid adding MemberExpression dependencies which would other evaluate during
* the mutable ranges of their base objects.
* This is different from `aliased-nested-scope-truncated-dep` which *does*
* produce correct output regardless of MemberExpression dependency truncation.
*
* Note while other expressions evaluate inline, function expressions *always*
* represent deferred evaluation. This means that
* (1) it's always safe to reorder function expression creation until its
* earliest potential invocation
* (2) it's invalid to eagerly evaluate function expression dependencies during
* their respective mutable ranges.
*/
function Component({prop}) {
let obj = shallowCopy(prop);
const aliasedObj = identity(obj);
// When `obj` is mutable (either directly or through aliases), taking a
// dependency on `obj.id` is invalid as it may change before getId() is invoked
const getId = () => obj.id;
mutate(aliasedObj);
setPropertyByKey(aliasedObj, 'id', prop.id + 1);
// Calling getId() should return prop.id + 1, not the prev
return <Stringify getId={getId} shouldInvokeFns={true} />;
}
export const FIXTURE_ENTRYPOINT = {
fn: Component,
params: [{prop: {id: 1}}],
sequentialRenders: [{prop: {id: 1}}, {prop: {id: 1}}, {prop: {id: 2}}],
};
Domain
Subdomains
Functions
Dependencies
- shared-runtime
Source
Frequently Asked Questions
What does aliased-nested-scope-fn-expr.tsx do?
aliased-nested-scope-fn-expr.tsx is a source file in the react codebase, written in tsx. It belongs to the TestingUtilities domain, Fixtures subdomain.
What functions are defined in aliased-nested-scope-fn-expr.tsx?
aliased-nested-scope-fn-expr.tsx defines 1 function(s): Component.
What does aliased-nested-scope-fn-expr.tsx depend on?
aliased-nested-scope-fn-expr.tsx imports 1 module(s): shared-runtime.
Where is aliased-nested-scope-fn-expr.tsx in the architecture?
aliased-nested-scope-fn-expr.tsx is located at compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/aliased-nested-scope-fn-expr.tsx (domain: TestingUtilities, subdomain: Fixtures, directory: compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free