getProperty() — react Function Reference
Architecture documentation for the getProperty() function in PropagateScopeDependenciesHIR.ts from the react codebase.
Entity Profile
Dependency Diagram
graph TD db4024a2_9da3_3c5b_55ec_ad3da742fbea["getProperty()"] 76832af2_c0a7_f31c_e448_af5664da4b88["PropagateScopeDependenciesHIR.ts"] db4024a2_9da3_3c5b_55ec_ad3da742fbea -->|defined in| 76832af2_c0a7_f31c_e448_af5664da4b88 bd383390_a354_8863_d439_cafcd9e7a730["collectTemporariesSidemapImpl()"] bd383390_a354_8863_d439_cafcd9e7a730 -->|calls| db4024a2_9da3_3c5b_55ec_ad3da742fbea 8d8b17be_69f6_c901_0c65_675b2f52ffc0["visitProperty()"] 8d8b17be_69f6_c901_0c65_675b2f52ffc0 -->|calls| db4024a2_9da3_3c5b_55ec_ad3da742fbea style db4024a2_9da3_3c5b_55ec_ad3da742fbea fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
compiler/packages/babel-plugin-react-compiler/src/HIR/PropagateScopeDependenciesHIR.ts lines 338–384
function getProperty(
object: Place,
propertyName: PropertyLiteral,
optional: boolean,
temporaries: ReadonlyMap<IdentifierId, ReactiveScopeDependency>,
): ReactiveScopeDependency {
/*
* (1) Get the base object either from the temporary sidemap (e.g. a LoadLocal)
* or a deep copy of an existing property dependency.
* Example 1:
* $0 = LoadLocal x
* $1 = PropertyLoad $0.y
* getProperty($0, ...) -> resolvedObject = x, resolvedDependency = null
*
* Example 2:
* $0 = LoadLocal x
* $1 = PropertyLoad $0.y
* $2 = PropertyLoad $1.z
* getProperty($1, ...) -> resolvedObject = null, resolvedDependency = x.y
*
* Example 3:
* $0 = Call(...)
* $1 = PropertyLoad $0.y
* getProperty($0, ...) -> resolvedObject = null, resolvedDependency = null
*/
const resolvedDependency = temporaries.get(object.identifier.id);
/**
* (2) Push the last PropertyLoad
* TODO(mofeiZ): understand optional chaining
*/
let property: ReactiveScopeDependency;
if (resolvedDependency == null) {
property = {
identifier: object.identifier,
reactive: object.reactive,
path: [{property: propertyName, optional}],
};
} else {
property = {
identifier: resolvedDependency.identifier,
reactive: resolvedDependency.reactive,
path: [...resolvedDependency.path, {property: propertyName, optional}],
};
}
return property;
}
Domain
Subdomains
Source
Frequently Asked Questions
What does getProperty() do?
getProperty() is a function in the react codebase, defined in compiler/packages/babel-plugin-react-compiler/src/HIR/PropagateScopeDependenciesHIR.ts.
Where is getProperty() defined?
getProperty() is defined in compiler/packages/babel-plugin-react-compiler/src/HIR/PropagateScopeDependenciesHIR.ts at line 338.
What calls getProperty()?
getProperty() is called by 2 function(s): collectTemporariesSidemapImpl, visitProperty.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free