reduceMaybeOptionalChains() — react Function Reference
Architecture documentation for the reduceMaybeOptionalChains() function in CollectHoistablePropertyLoads.ts from the react codebase.
Entity Profile
Dependency Diagram
graph TD bc0d4a49_256e_973f_feb6_ed785896b72b["reduceMaybeOptionalChains()"] 53e05ed1_ffb1_8db2_8573_ef5a3fb99c72["CollectHoistablePropertyLoads.ts"] bc0d4a49_256e_973f_feb6_ed785896b72b -->|defined in| 53e05ed1_ffb1_8db2_8573_ef5a3fb99c72 73ed54f2_d6a7_c7ec_9243_c999d99e8329["propagateNonNull()"] 73ed54f2_d6a7_c7ec_9243_c999d99e8329 -->|calls| bc0d4a49_256e_973f_feb6_ed785896b72b 0c8c1a1b_48b7_ed11_7af0_b4cb1faadd61["Set_filter()"] bc0d4a49_256e_973f_feb6_ed785896b72b -->|calls| 0c8c1a1b_48b7_ed11_7af0_b4cb1faadd61 084ee472_d720_c32a_2f8a_dffbbb1be6af["getOrCreateIdentifier()"] bc0d4a49_256e_973f_feb6_ed785896b72b -->|calls| 084ee472_d720_c32a_2f8a_dffbbb1be6af a6cc066a_d685_3022_a631_437bad493e6d["getOrCreatePropertyEntry()"] bc0d4a49_256e_973f_feb6_ed785896b72b -->|calls| a6cc066a_d685_3022_a631_437bad493e6d style bc0d4a49_256e_973f_feb6_ed785896b72b fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
compiler/packages/babel-plugin-react-compiler/src/HIR/CollectHoistablePropertyLoads.ts lines 644–683
function reduceMaybeOptionalChains(
nodes: Set<PropertyPathNode>,
registry: PropertyPathRegistry,
): void {
let optionalChainNodes = Set_filter(nodes, n => n.hasOptional);
if (optionalChainNodes.size === 0) {
return;
}
let changed: boolean;
do {
changed = false;
for (const original of optionalChainNodes) {
let {identifier, path: origPath, reactive} = original.fullPath;
let currNode: PropertyPathNode = registry.getOrCreateIdentifier(
identifier,
reactive,
);
for (let i = 0; i < origPath.length; i++) {
const entry = origPath[i];
// If the base is known to be non-null, replace with a non-optional load
const nextEntry: DependencyPathEntry =
entry.optional && nodes.has(currNode)
? {property: entry.property, optional: false}
: entry;
currNode = PropertyPathRegistry.getOrCreatePropertyEntry(
currNode,
nextEntry,
);
}
if (currNode !== original) {
changed = true;
optionalChainNodes.delete(original);
optionalChainNodes.add(currNode);
nodes.delete(original);
nodes.add(currNode);
}
}
} while (changed);
}
Domain
Subdomains
Called By
Source
Frequently Asked Questions
What does reduceMaybeOptionalChains() do?
reduceMaybeOptionalChains() is a function in the react codebase, defined in compiler/packages/babel-plugin-react-compiler/src/HIR/CollectHoistablePropertyLoads.ts.
Where is reduceMaybeOptionalChains() defined?
reduceMaybeOptionalChains() is defined in compiler/packages/babel-plugin-react-compiler/src/HIR/CollectHoistablePropertyLoads.ts at line 644.
What does reduceMaybeOptionalChains() call?
reduceMaybeOptionalChains() calls 3 function(s): Set_filter, getOrCreateIdentifier, getOrCreatePropertyEntry.
What calls reduceMaybeOptionalChains()?
reduceMaybeOptionalChains() is called by 1 function(s): propagateNonNull.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free