transformScope() — react Function Reference
Architecture documentation for the transformScope() function in PruneUnusedScopes.ts from the react codebase.
Entity Profile
Dependency Diagram
graph TD 4f7ad929_f19e_7d55_33f1_e3306e7e41bc["transformScope()"] 5a05f31c_ebbc_2227_1399_e3e8c8cbcfa3["Transform"] 4f7ad929_f19e_7d55_33f1_e3306e7e41bc -->|defined in| 5a05f31c_ebbc_2227_1399_e3e8c8cbcfa3 4acb57df_5348_9aab_9691_41cf35127db4["visitScope()"] 4f7ad929_f19e_7d55_33f1_e3306e7e41bc -->|calls| 4acb57df_5348_9aab_9691_41cf35127db4 b639747b_32c3_a4bf_867f_dba5d3901073["transformScope()"] 4f7ad929_f19e_7d55_33f1_e3306e7e41bc -->|calls| b639747b_32c3_a4bf_867f_dba5d3901073 63729a7b_662e_cdeb_1679_8ae36c41d27f["hasOwnDeclaration()"] 4f7ad929_f19e_7d55_33f1_e3306e7e41bc -->|calls| 63729a7b_662e_cdeb_1679_8ae36c41d27f style 4f7ad929_f19e_7d55_33f1_e3306e7e41bc fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
compiler/packages/babel-plugin-react-compiler/src/ReactiveScopes/PruneUnusedScopes.ts lines 38–65
override transformScope(
scopeBlock: ReactiveScopeBlock,
_state: State,
): Transformed<ReactiveStatement> {
const scopeState: State = {hasReturnStatement: false};
this.visitScope(scopeBlock, scopeState);
if (
!scopeState.hasReturnStatement &&
scopeBlock.scope.reassignments.size === 0 &&
(scopeBlock.scope.declarations.size === 0 ||
/*
* Can prune scopes where all declarations bubbled up from inner
* scopes
*/
!hasOwnDeclaration(scopeBlock))
) {
return {
kind: 'replace',
value: {
kind: 'pruned-scope',
scope: scopeBlock.scope,
instructions: scopeBlock.instructions,
},
};
} else {
return {kind: 'keep'};
}
}
Domain
Subdomains
Source
Frequently Asked Questions
What does transformScope() do?
transformScope() is a function in the react codebase, defined in compiler/packages/babel-plugin-react-compiler/src/ReactiveScopes/PruneUnusedScopes.ts.
Where is transformScope() defined?
transformScope() is defined in compiler/packages/babel-plugin-react-compiler/src/ReactiveScopes/PruneUnusedScopes.ts at line 38.
What does transformScope() call?
transformScope() calls 3 function(s): hasOwnDeclaration, transformScope, visitScope.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free