inferDependencies() — react Function Reference
Architecture documentation for the inferDependencies() function in InferEffectDependencies.ts from the react codebase.
Entity Profile
Dependency Diagram
graph TD f523a4df_e5a4_d8d8_dbd0_ef75659ea0a5["inferDependencies()"] 3393f920_76eb_7dd5_b95f_ab92de6cecce["InferEffectDependencies.ts"] f523a4df_e5a4_d8d8_dbd0_ef75659ea0a5 -->|defined in| 3393f920_76eb_7dd5_b95f_ab92de6cecce ca434b67_031d_2bec_f10c_3b8a790002ed["inferMinimalDependencies()"] ca434b67_031d_2bec_f10c_3b8a790002ed -->|calls| f523a4df_e5a4_d8d8_dbd0_ef75659ea0a5 97736ed1_9768_bb5a_276e_d5b04a417908["declare()"] f523a4df_e5a4_d8d8_dbd0_ef75659ea0a5 -->|calls| 97736ed1_9768_bb5a_276e_d5b04a417908 462d4884_0290_ceb1_b76b_bfb25c49a3cc["empty()"] f523a4df_e5a4_d8d8_dbd0_ef75659ea0a5 -->|calls| 462d4884_0290_ceb1_b76b_bfb25c49a3cc ad463e10_0394_9f8b_1e38_c1e95a00ff97["enterScope()"] f523a4df_e5a4_d8d8_dbd0_ef75659ea0a5 -->|calls| ad463e10_0394_9f8b_1e38_c1e95a00ff97 ad17cc28_c934_cf1a_ce40_409d2c34592d["inferDependenciesInFn()"] f523a4df_e5a4_d8d8_dbd0_ef75659ea0a5 -->|calls| ad17cc28_c934_cf1a_ce40_409d2c34592d fa34629f_c89e_a9bf_4c20_ec6a2b54a55c["exitScope()"] f523a4df_e5a4_d8d8_dbd0_ef75659ea0a5 -->|calls| fa34629f_c89e_a9bf_4c20_ec6a2b54a55c style f523a4df_e5a4_d8d8_dbd0_ef75659ea0a5 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
compiler/packages/babel-plugin-react-compiler/src/Inference/InferEffectDependencies.ts lines 588–637
function inferDependencies(
fnInstr: TInstruction<FunctionExpression>,
temporaries: ReadonlyMap<IdentifierId, ReactiveScopeDependency>,
processedInstrsInOptional: ReadonlySet<Instruction | Terminal>,
): Set<ReactiveScopeDependency> {
const fn = fnInstr.value.loweredFunc.func;
const context = new DependencyCollectionContext(
new Set(),
temporaries,
processedInstrsInOptional,
);
for (const dep of fn.context) {
context.declare(dep.identifier, {
id: makeInstructionId(0),
scope: empty(),
});
}
const placeholderScope: ReactiveScope = {
id: makeScopeId(0),
range: {
start: fnInstr.id,
end: makeInstructionId(fnInstr.id + 1),
},
dependencies: new Set(),
reassignments: new Set(),
declarations: new Map(),
earlyReturnValue: null,
merged: new Set(),
loc: GeneratedSource,
};
context.enterScope(placeholderScope);
inferDependenciesInFn(fn, context, temporaries);
context.exitScope(placeholderScope, false);
const resultUnfiltered = context.deps.get(placeholderScope);
CompilerError.invariant(resultUnfiltered != null, {
reason:
'[InferEffectDependencies] Internal invariant broken: missing scope dependencies',
loc: fn.loc,
});
const fnContext = new Set(fn.context.map(dep => dep.identifier.id));
const result = new Set<ReactiveScopeDependency>();
for (const dep of resultUnfiltered) {
if (fnContext.has(dep.identifier.id)) {
result.add(dep);
}
}
return result;
}
Domain
Subdomains
Called By
Source
Frequently Asked Questions
What does inferDependencies() do?
inferDependencies() is a function in the react codebase, defined in compiler/packages/babel-plugin-react-compiler/src/Inference/InferEffectDependencies.ts.
Where is inferDependencies() defined?
inferDependencies() is defined in compiler/packages/babel-plugin-react-compiler/src/Inference/InferEffectDependencies.ts at line 588.
What does inferDependencies() call?
inferDependencies() calls 5 function(s): declare, empty, enterScope, exitScope, inferDependenciesInFn.
What calls inferDependencies()?
inferDependencies() is called by 1 function(s): inferMinimalDependencies.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free