getFunctionName() — react Function Reference
Architecture documentation for the getFunctionName() function in Program.ts from the react codebase.
Entity Profile
Dependency Diagram
graph TD 1351f300_d3f0_8ef1_7520_1bc143225b34["getFunctionName()"] 9aa4477d_960b_1ea1_b6d9_36076aaa70bd["Program.ts"] 1351f300_d3f0_8ef1_7520_1bc143225b34 -->|defined in| 9aa4477d_960b_1ea1_b6d9_36076aaa70bd 6f61e521_79f8_315c_2443_8700d7e01eaa["validateNoDynamicallyCreatedComponentsOrHooks()"] 6f61e521_79f8_315c_2443_8700d7e01eaa -->|calls| 1351f300_d3f0_8ef1_7520_1bc143225b34 2bfe28c2_c730_2f65_86db_f782c4b5a3e5["getComponentOrHookLike()"] 2bfe28c2_c730_2f65_86db_f782c4b5a3e5 -->|calls| 1351f300_d3f0_8ef1_7520_1bc143225b34 58e83968_5fd8_9e9f_e4be_1f50e95f54dc["getFunctionReferencedBeforeDeclarationAtTopLevel()"] 58e83968_5fd8_9e9f_e4be_1f50e95f54dc -->|calls| 1351f300_d3f0_8ef1_7520_1bc143225b34 style 1351f300_d3f0_8ef1_7520_1bc143225b34 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
compiler/packages/babel-plugin-react-compiler/src/Entrypoint/Program.ts lines 1310–1364
function getFunctionName(
path: NodePath<
t.FunctionDeclaration | t.ArrowFunctionExpression | t.FunctionExpression
>,
): NodePath<t.Expression> | null {
if (path.isFunctionDeclaration()) {
const id = path.get('id');
if (id.isIdentifier()) {
return id;
}
return null;
}
let id: NodePath<t.LVal | t.Expression | t.PrivateName> | null = null;
const parent = path.parentPath;
if (parent.isVariableDeclarator() && parent.get('init').node === path.node) {
// const useHook = () => {};
id = parent.get('id');
} else if (
parent.isAssignmentExpression() &&
parent.get('right').node === path.node &&
parent.get('operator') === '='
) {
// useHook = () => {};
id = parent.get('left');
} else if (
parent.isProperty() &&
parent.get('value').node === path.node &&
!parent.get('computed') &&
parent.get('key').isLVal()
) {
/*
* {useHook: () => {}}
* {useHook() {}}
*/
id = parent.get('key');
} else if (
parent.isAssignmentPattern() &&
parent.get('right').node === path.node &&
!parent.get('computed')
) {
/*
* const {useHook = () => {}} = {};
* ({useHook = () => {}} = {});
*
* Kinda clowny, but we'd said we'd follow spec convention for
* `IsAnonymousFunctionDefinition()` usage.
*/
id = parent.get('left');
}
if (id !== null && (id.isIdentifier() || id.isMemberExpression())) {
return id;
} else {
return null;
}
}
Domain
Subdomains
Called By
Source
Frequently Asked Questions
What does getFunctionName() do?
getFunctionName() is a function in the react codebase, defined in compiler/packages/babel-plugin-react-compiler/src/Entrypoint/Program.ts.
Where is getFunctionName() defined?
getFunctionName() is defined in compiler/packages/babel-plugin-react-compiler/src/Entrypoint/Program.ts at line 1310.
What calls getFunctionName()?
getFunctionName() is called by 3 function(s): getComponentOrHookLike, getFunctionReferencedBeforeDeclarationAtTopLevel, validateNoDynamicallyCreatedComponentsOrHooks.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free