nodeContainsHookVariableName() — react Function Reference
Architecture documentation for the nodeContainsHookVariableName() function in astUtils.js from the react codebase.
Entity Profile
Dependency Diagram
graph TD f6deeb57_f62f_467f_fc8e_73ff4e2df353["nodeContainsHookVariableName()"] 22acaf1d_d624_cc04_9046_5e8603f3a58d["astUtils.js"] f6deeb57_f62f_467f_fc8e_73ff4e2df353 -->|defined in| 22acaf1d_d624_cc04_9046_5e8603f3a58d 8f20542e_3cd7_577b_d616_7755284e5d75["getFilteredHookASTNodes()"] 8f20542e_3cd7_577b_d616_7755284e5d75 -->|calls| f6deeb57_f62f_467f_fc8e_73ff4e2df353 4fc49527_bab5_ef0d_7ef1_b39e407cd165["isBuiltInHookThatReturnsTuple()"] f6deeb57_f62f_467f_fc8e_73ff4e2df353 -->|calls| 4fc49527_bab5_ef0d_7ef1_b39e407cd165 style f6deeb57_f62f_467f_fc8e_73ff4e2df353 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/react-devtools-shared/src/hooks/astUtils.js lines 608–630
function nodeContainsHookVariableName(hookNode: NodePath): boolean {
// We determine cases where variable names are obvious in declarations. Examples:
// const [tick, setTick] = useState(1); OR const ref = useRef(null);
// Here tick/ref are obvious hook variables in the hook declaration node itself
// 1. True for satisfying above cases
// 2. False for everything else. Examples:
// const countState = React.useState(0);
// const count = countState[0];
// const setCount = countState[1]; -> not obvious, hook variable can't be determined
// from the hook declaration node alone
// 3. For custom hooks we force pass true since we are only concerned with the AST node
// regardless of how it is accessed in source code. (See: getHookVariableName)
const node = hookNode.node.id;
if (
node.type === AST_NODE_TYPES.ARRAY_PATTERN ||
(node.type === AST_NODE_TYPES.IDENTIFIER &&
!isBuiltInHookThatReturnsTuple(hookNode))
) {
return true;
}
return false;
}
Domain
Subdomains
Called By
Source
Frequently Asked Questions
What does nodeContainsHookVariableName() do?
nodeContainsHookVariableName() is a function in the react codebase, defined in packages/react-devtools-shared/src/hooks/astUtils.js.
Where is nodeContainsHookVariableName() defined?
nodeContainsHookVariableName() is defined in packages/react-devtools-shared/src/hooks/astUtils.js at line 608.
What does nodeContainsHookVariableName() call?
nodeContainsHookVariableName() calls 1 function(s): isBuiltInHookThatReturnsTuple.
What calls nodeContainsHookVariableName()?
nodeContainsHookVariableName() is called by 1 function(s): getFilteredHookASTNodes.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free