visitTerminal() — react Function Reference
Architecture documentation for the visitTerminal() function in PruneNonEscapingScopes.ts from the react codebase.
Entity Profile
Dependency Diagram
graph TD a2b8864c_bfaf_d2f0_5221_fa3f55effd1e["visitTerminal()"] 34688860_6e1e_6179_5b2b_d4681c2cfce3["CollectDependenciesVisitor"] a2b8864c_bfaf_d2f0_5221_fa3f55effd1e -->|defined in| 34688860_6e1e_6179_5b2b_d4681c2cfce3 81772aef_ba02_c42b_7791_2496bf4c50b4["visitTerminal()"] a2b8864c_bfaf_d2f0_5221_fa3f55effd1e -->|calls| 81772aef_ba02_c42b_7791_2496bf4c50b4 54d623b1_ac7c_dd74_8b03_de9e93a36587["invariant()"] a2b8864c_bfaf_d2f0_5221_fa3f55effd1e -->|calls| 54d623b1_ac7c_dd74_8b03_de9e93a36587 949e1f0f_be13_a7db_fc83_cab2bd3155db["traverseTerminal()"] a2b8864c_bfaf_d2f0_5221_fa3f55effd1e -->|calls| 949e1f0f_be13_a7db_fc83_cab2bd3155db style a2b8864c_bfaf_d2f0_5221_fa3f55effd1e fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
compiler/packages/babel-plugin-react-compiler/src/ReactiveScopes/PruneNonEscapingScopes.ts lines 952–981
override visitTerminal(
stmt: ReactiveTerminalStatement<ReactiveTerminal>,
scopes: Array<ReactiveScope>,
): void {
this.traverseTerminal(stmt, scopes);
if (stmt.terminal.kind === 'return') {
this.state.escapingValues.add(
stmt.terminal.value.identifier.declarationId,
);
/*
* If the return is within a scope, then those scopes must be evaluated
* with the return and should be considered dependencies of the returned
* value.
*
* This ensures that if those scopes have dependencies that those deps
* are also memoized.
*/
const identifierNode = this.state.identifiers.get(
stmt.terminal.value.identifier.declarationId,
);
CompilerError.invariant(identifierNode !== undefined, {
reason: 'Expected identifier to be initialized',
loc: stmt.terminal.loc,
});
for (const scope of scopes) {
identifierNode.scopes.add(scope.id);
}
}
}
Domain
Subdomains
Defined In
Source
Frequently Asked Questions
What does visitTerminal() do?
visitTerminal() is a function in the react codebase, defined in compiler/packages/babel-plugin-react-compiler/src/ReactiveScopes/PruneNonEscapingScopes.ts.
Where is visitTerminal() defined?
visitTerminal() is defined in compiler/packages/babel-plugin-react-compiler/src/ReactiveScopes/PruneNonEscapingScopes.ts at line 952.
What does visitTerminal() call?
visitTerminal() calls 3 function(s): invariant, traverseTerminal, visitTerminal.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free