Component() — react Function Reference
Architecture documentation for the Component() function in reactive-control-dependency-on-context-variable.js from the react codebase.
Entity Profile
Dependency Diagram
graph TD cdacc8d0_63e8_a8a1_57ff_ec84cb437497["Component()"] 82aa3bf9_a829_2ae5_5431_c4e029b1274f["reactive-control-dependency-on-context-variable.js"] cdacc8d0_63e8_a8a1_57ff_ec84cb437497 -->|defined in| 82aa3bf9_a829_2ae5_5431_c4e029b1274f style cdacc8d0_63e8_a8a1_57ff_ec84cb437497 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/reactive-control-dependency-on-context-variable.js lines 3–22
function Component(props) {
let x;
// Reassign `x` based on a reactive value, but inside a function expression
// to make it a context variable
const f = () => {
if (props.cond) {
x = 1;
} else {
x = 2;
}
};
// Pass `f` through a function to prevent IIFE inlining optimizations
const f2 = identity(f);
f2();
// The values assigned to `x` are non-reactive, but the value of `x`
// depends on the "control" value `props.cond` which is reactive.
// Therefore x should be treated as reactive too.
return [x];
}
Domain
Subdomains
Source
Frequently Asked Questions
What does Component() do?
Component() is a function in the react codebase, defined in compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/reactive-control-dependency-on-context-variable.js.
Where is Component() defined?
Component() is defined in compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/reactive-control-dependency-on-context-variable.js at line 3.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free