buildTreeNode() — react Function Reference
Architecture documentation for the buildTreeNode() function in ValidateNoDerivedComputationsInEffects_exp.ts from the react codebase.
Entity Profile
Dependency Diagram
graph TD 4feac835_0880_bcc2_9f00_76a93e1332ef["buildTreeNode()"] a38a9d1f_969c_8056_aa80_6cb5fedba226["ValidateNoDerivedComputationsInEffects_exp.ts"] 4feac835_0880_bcc2_9f00_76a93e1332ef -->|defined in| a38a9d1f_969c_8056_aa80_6cb5fedba226 8014ef2c_7e1b_b1da_b888_615d609f3c01["validateEffect()"] 8014ef2c_7e1b_b1da_b888_615d609f3c01 -->|calls| 4feac835_0880_bcc2_9f00_76a93e1332ef 4139c139_7133_9f5e_2214_ba1d9b9558ec["isNamedIdentifier()"] 4feac835_0880_bcc2_9f00_76a93e1332ef -->|calls| 4139c139_7133_9f5e_2214_ba1d9b9558ec 041ca752_10c1_3cda_1f5c_02f44a01310e["invariant()"] 4feac835_0880_bcc2_9f00_76a93e1332ef -->|calls| 041ca752_10c1_3cda_1f5c_02f44a01310e 073c81a5_c389_d108_5b8f_4d6dc6eece83["push()"] 4feac835_0880_bcc2_9f00_76a93e1332ef -->|calls| 073c81a5_c389_d108_5b8f_4d6dc6eece83 style 4feac835_0880_bcc2_9f00_76a93e1332ef fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
compiler/packages/babel-plugin-react-compiler/src/Validation/ValidateNoDerivedComputationsInEffects_exp.ts lines 501–567
function buildTreeNode(
sourceId: IdentifierId,
context: ValidationContext,
visited: Set<string> = new Set(),
): Array<TreeNode> {
const sourceMetadata = context.derivationCache.cache.get(sourceId);
if (!sourceMetadata) {
return [];
}
if (sourceMetadata.isStateSource && isNamedIdentifier(sourceMetadata.place)) {
return [
{
name: sourceMetadata.place.identifier.name.value,
typeOfValue: sourceMetadata.typeOfValue,
isSource: sourceMetadata.isStateSource,
children: [],
},
];
}
const children: Array<TreeNode> = [];
const namedSiblings: Set<string> = new Set();
for (const childId of sourceMetadata.sourcesIds) {
CompilerError.invariant(childId !== sourceId, {
reason:
'Unexpected self-reference: a value should not have itself as a source',
loc: sourceMetadata.place.loc,
});
const childNodes = buildTreeNode(
childId,
context,
new Set([
...visited,
...(isNamedIdentifier(sourceMetadata.place)
? [sourceMetadata.place.identifier.name.value]
: []),
]),
);
if (childNodes) {
for (const childNode of childNodes) {
if (!namedSiblings.has(childNode.name)) {
children.push(childNode);
namedSiblings.add(childNode.name);
}
}
}
}
if (
isNamedIdentifier(sourceMetadata.place) &&
!visited.has(sourceMetadata.place.identifier.name.value)
) {
return [
{
name: sourceMetadata.place.identifier.name.value,
typeOfValue: sourceMetadata.typeOfValue,
isSource: sourceMetadata.isStateSource,
children: children,
},
];
}
return children;
}
Domain
Subdomains
Called By
Source
Frequently Asked Questions
What does buildTreeNode() do?
buildTreeNode() is a function in the react codebase, defined in compiler/packages/babel-plugin-react-compiler/src/Validation/ValidateNoDerivedComputationsInEffects_exp.ts.
Where is buildTreeNode() defined?
buildTreeNode() is defined in compiler/packages/babel-plugin-react-compiler/src/Validation/ValidateNoDerivedComputationsInEffects_exp.ts at line 501.
What does buildTreeNode() call?
buildTreeNode() calls 3 function(s): invariant, isNamedIdentifier, push.
What calls buildTreeNode()?
buildTreeNode() is called by 1 function(s): validateEffect.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free