pruneNonEscapingScopes() — react Function Reference
Architecture documentation for the pruneNonEscapingScopes() function in PruneNonEscapingScopes.ts from the react codebase.
Entity Profile
Dependency Diagram
graph TD d832b21e_d654_e993_f855_4556f97c1e2d["pruneNonEscapingScopes()"] c4112963_95fe_d8ed_3bfd_f6d45887acb7["PruneNonEscapingScopes.ts"] d832b21e_d654_e993_f855_4556f97c1e2d -->|defined in| c4112963_95fe_d8ed_3bfd_f6d45887acb7 73ad0fca_8aa6_a337_83a0_3ddb7277f89c["declare()"] d832b21e_d654_e993_f855_4556f97c1e2d -->|calls| 73ad0fca_8aa6_a337_83a0_3ddb7277f89c 2435b5f8_41a6_0458_ba88_4479b965455f["visitReactiveFunction()"] d832b21e_d654_e993_f855_4556f97c1e2d -->|calls| 2435b5f8_41a6_0458_ba88_4479b965455f 6cbc6f54_5202_efe6_f13a_d6f4722effbc["computeMemoizedIdentifiers()"] d832b21e_d654_e993_f855_4556f97c1e2d -->|calls| 6cbc6f54_5202_efe6_f13a_d6f4722effbc style d832b21e_d654_e993_f855_4556f97c1e2d fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
compiler/packages/babel-plugin-react-compiler/src/ReactiveScopes/PruneNonEscapingScopes.ts lines 113–136
export function pruneNonEscapingScopes(fn: ReactiveFunction): void {
/*
* First build up a map of which instructions are involved in creating which values,
* and which values are returned.
*/
const state = new State(fn.env);
for (const param of fn.params) {
if (param.kind === 'Identifier') {
state.declare(param.identifier.declarationId);
} else {
state.declare(param.place.identifier.declarationId);
}
}
visitReactiveFunction(fn, new CollectDependenciesVisitor(fn.env, state), []);
/*
* Then walk outward from the returned values and find all captured operands.
* This forms the set of identifiers which should be memoized.
*/
const memoized = computeMemoizedIdentifiers(state);
// Prune scopes that do not declare/reassign any escaping values
visitReactiveFunction(fn, new PruneScopesTransform(), memoized);
}
Domain
Subdomains
Defined In
Source
Frequently Asked Questions
What does pruneNonEscapingScopes() do?
pruneNonEscapingScopes() is a function in the react codebase, defined in compiler/packages/babel-plugin-react-compiler/src/ReactiveScopes/PruneNonEscapingScopes.ts.
Where is pruneNonEscapingScopes() defined?
pruneNonEscapingScopes() is defined in compiler/packages/babel-plugin-react-compiler/src/ReactiveScopes/PruneNonEscapingScopes.ts at line 113.
What does pruneNonEscapingScopes() call?
pruneNonEscapingScopes() calls 3 function(s): computeMemoizedIdentifiers, declare, visitReactiveFunction.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free