visitScope() — react Function Reference
Architecture documentation for the visitScope() function in PruneNonEscapingScopes.ts from the react codebase.
Entity Profile
Dependency Diagram
graph TD 8964b840_74b5_2c96_c227_89dd281fdf38["visitScope()"] 714af45f_cbe2_027b_49c5_27e47069c22c["CollectDependenciesVisitor"] 8964b840_74b5_2c96_c227_89dd281fdf38 -->|defined in| 714af45f_cbe2_027b_49c5_27e47069c22c f6b0f572_362c_d22e_89ed_27e1eef4d74e["transformScope()"] f6b0f572_362c_d22e_89ed_27e1eef4d74e -->|calls| 8964b840_74b5_2c96_c227_89dd281fdf38 2eebfc2b_b1f6_9f25_ad32_78be0b56f06b["traverseScope()"] 8964b840_74b5_2c96_c227_89dd281fdf38 -->|calls| 2eebfc2b_b1f6_9f25_ad32_78be0b56f06b 4acb57df_5348_9aab_9691_41cf35127db4["visitScope()"] 8964b840_74b5_2c96_c227_89dd281fdf38 -->|calls| 4acb57df_5348_9aab_9691_41cf35127db4 041ca752_10c1_3cda_1f5c_02f44a01310e["invariant()"] 8964b840_74b5_2c96_c227_89dd281fdf38 -->|calls| 041ca752_10c1_3cda_1f5c_02f44a01310e style 8964b840_74b5_2c96_c227_89dd281fdf38 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
compiler/packages/babel-plugin-react-compiler/src/ReactiveScopes/PruneNonEscapingScopes.ts lines 983–1007
override visitScope(
scope: ReactiveScopeBlock,
scopes: Array<ReactiveScope>,
): void {
/*
* If a scope reassigns any variables, set the chain of active scopes as a dependency
* of those variables. This ensures that if the variable escapes that we treat the
* reassignment scopes — and importantly their dependencies — as needing memoization.
*/
for (const reassignment of scope.scope.reassignments) {
const identifierNode = this.state.identifiers.get(
reassignment.declarationId,
);
CompilerError.invariant(identifierNode !== undefined, {
reason: 'Expected identifier to be initialized',
loc: reassignment.loc,
});
for (const scope of scopes) {
identifierNode.scopes.add(scope.id);
}
identifierNode.scopes.add(scope.scope.id);
}
this.traverseScope(scope, [...scopes, scope.scope]);
}
Domain
Subdomains
Defined In
Called By
Source
Frequently Asked Questions
What does visitScope() do?
visitScope() is a function in the react codebase, defined in compiler/packages/babel-plugin-react-compiler/src/ReactiveScopes/PruneNonEscapingScopes.ts.
Where is visitScope() defined?
visitScope() is defined in compiler/packages/babel-plugin-react-compiler/src/ReactiveScopes/PruneNonEscapingScopes.ts at line 983.
What does visitScope() call?
visitScope() calls 3 function(s): invariant, traverseScope, visitScope.
What calls visitScope()?
visitScope() is called by 1 function(s): transformScope.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free