getReactiveHookCallbackIndex() — react Function Reference
Architecture documentation for the getReactiveHookCallbackIndex() function in ExhaustiveDeps.ts from the react codebase.
Entity Profile
Dependency Diagram
graph TD 895f966f_4edb_0ba3_8a49_6adf99e31ec1["getReactiveHookCallbackIndex()"] ea02b01a_dd46_4b35_fe00_775aec496668["ExhaustiveDeps.ts"] 895f966f_4edb_0ba3_8a49_6adf99e31ec1 -->|defined in| ea02b01a_dd46_4b35_fe00_775aec496668 c0937ffe_5980_6959_3af6_e18a4a23114f["rule.create()"] c0937ffe_5980_6959_3af6_e18a4a23114f -->|calls| 895f966f_4edb_0ba3_8a49_6adf99e31ec1 57d4575e_cb38_7d65_a871_8e1ae5d76a1f["getNodeWithoutReactNamespace()"] 895f966f_4edb_0ba3_8a49_6adf99e31ec1 -->|calls| 57d4575e_cb38_7d65_a871_8e1ae5d76a1f bf9b6b10_9341_d44c_d960_2c1a990db056["analyzePropertyChain()"] 895f966f_4edb_0ba3_8a49_6adf99e31ec1 -->|calls| bf9b6b10_9341_d44c_d960_2c1a990db056 style 895f966f_4edb_0ba3_8a49_6adf99e31ec1 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/eslint-plugin-react-hooks/src/rules/ExhaustiveDeps.ts lines 1990–2033
function getReactiveHookCallbackIndex(
calleeNode: Expression | Super,
options?: {
additionalHooks: RegExp | undefined;
enableDangerousAutofixThisMayCauseInfiniteLoops?: boolean;
},
): 0 | -1 | 1 {
const node = getNodeWithoutReactNamespace(calleeNode);
if (node.type !== 'Identifier') {
return -1;
}
switch (node.name) {
case 'useEffect':
case 'useLayoutEffect':
case 'useCallback':
case 'useMemo':
// useEffect(fn)
return 0;
case 'useImperativeHandle':
// useImperativeHandle(ref, fn)
return 1;
default:
if (node === calleeNode && options && options.additionalHooks) {
// Allow the user to provide a regular expression which enables the lint to
// target custom reactive hooks.
let name;
try {
name = analyzePropertyChain(node, null);
} catch (error: unknown) {
if (
error instanceof Error &&
/Unsupported node type/.test(error.message)
) {
return 0;
} else {
throw error;
}
}
return options.additionalHooks.test(name) ? 0 : -1;
} else {
return -1;
}
}
}
Domain
Subdomains
Called By
Source
Frequently Asked Questions
What does getReactiveHookCallbackIndex() do?
getReactiveHookCallbackIndex() is a function in the react codebase, defined in packages/eslint-plugin-react-hooks/src/rules/ExhaustiveDeps.ts.
Where is getReactiveHookCallbackIndex() defined?
getReactiveHookCallbackIndex() is defined in packages/eslint-plugin-react-hooks/src/rules/ExhaustiveDeps.ts at line 1990.
What does getReactiveHookCallbackIndex() call?
getReactiveHookCallbackIndex() calls 2 function(s): analyzePropertyChain, getNodeWithoutReactNamespace.
What calls getReactiveHookCallbackIndex()?
getReactiveHookCallbackIndex() is called by 1 function(s): rule.create.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free