isHook() — react Function Reference
Architecture documentation for the isHook() function in astUtils.js from the react codebase.
Entity Profile
Dependency Diagram
graph TD ba0d9569_23b0_9c1a_d1d4_ec900c053397["isHook()"] 22acaf1d_d624_cc04_9046_5e8603f3a58d["astUtils.js"] ba0d9569_23b0_9c1a_d1d4_ec900c053397 -->|defined in| 22acaf1d_d624_cc04_9046_5e8603f3a58d 1bf7e74a_96b7_ab97_b607_d0a528f9046e["isConfirmedHookDeclaration()"] 1bf7e74a_96b7_ab97_b607_d0a528f9046e -->|calls| ba0d9569_23b0_9c1a_d1d4_ec900c053397 380887ba_dbe4_1ba6_7743_9a77aad37654["isPotentialHookDeclaration()"] 380887ba_dbe4_1ba6_7743_9a77aad37654 -->|calls| ba0d9569_23b0_9c1a_d1d4_ec900c053397 0c2ffd64_7df9_5740_9825_16d1c8ea2642["isHookName()"] ba0d9569_23b0_9c1a_d1d4_ec900c053397 -->|calls| 0c2ffd64_7df9_5740_9825_16d1c8ea2642 style ba0d9569_23b0_9c1a_d1d4_ec900c053397 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/react-devtools-shared/src/hooks/astUtils.js lines 523–544
function isHook(node: Node): boolean {
if (node.type === AST_NODE_TYPES.IDENTIFIER) {
return isHookName(node.name);
} else if (
node.type === AST_NODE_TYPES.MEMBER_EXPRESSION &&
!node.computed &&
isHook(node.property)
) {
const obj = node.object;
const isPascalCaseNameSpace = /^[A-Z].*/;
return (
obj.type === AST_NODE_TYPES.IDENTIFIER &&
isPascalCaseNameSpace.test(obj.name)
);
} else {
// TODO Possibly handle inline require statements e.g. require("useStable")(...)
// This does not seem like a high priority, since inline requires are probably
// not common and are also typically in compiled code rather than source code.
return false;
}
}
Domain
Subdomains
Calls
Source
Frequently Asked Questions
What does isHook() do?
isHook() is a function in the react codebase, defined in packages/react-devtools-shared/src/hooks/astUtils.js.
Where is isHook() defined?
isHook() is defined in packages/react-devtools-shared/src/hooks/astUtils.js at line 523.
What does isHook() call?
isHook() calls 1 function(s): isHookName.
What calls isHook()?
isHook() is called by 2 function(s): isConfirmedHookDeclaration, isPotentialHookDeclaration.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free