Home / Function/ analyzePropertyChain() — react Function Reference

analyzePropertyChain() — react Function Reference

Architecture documentation for the analyzePropertyChain() function in ExhaustiveDeps.ts from the react codebase.

Entity Profile

Dependency Diagram

graph TD
  bf9b6b10_9341_d44c_d960_2c1a990db056["analyzePropertyChain()"]
  ea02b01a_dd46_4b35_fe00_775aec496668["ExhaustiveDeps.ts"]
  bf9b6b10_9341_d44c_d960_2c1a990db056 -->|defined in| ea02b01a_dd46_4b35_fe00_775aec496668
  895f966f_4edb_0ba3_8a49_6adf99e31ec1["getReactiveHookCallbackIndex()"]
  895f966f_4edb_0ba3_8a49_6adf99e31ec1 -->|calls| bf9b6b10_9341_d44c_d960_2c1a990db056
  c0937ffe_5980_6959_3af6_e18a4a23114f["rule.create()"]
  c0937ffe_5980_6959_3af6_e18a4a23114f -->|calls| bf9b6b10_9341_d44c_d960_2c1a990db056
  de7f78c0_3370_f4c0_ba0d_ed04d502120f["markNode()"]
  bf9b6b10_9341_d44c_d960_2c1a990db056 -->|calls| de7f78c0_3370_f4c0_ba0d_ed04d502120f
  style bf9b6b10_9341_d44c_d960_2c1a990db056 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/eslint-plugin-react-hooks/src/rules/ExhaustiveDeps.ts lines 1927–1968

function analyzePropertyChain(
  node: Node,
  optionalChains: Map<string, boolean> | null,
): string {
  if (node.type === 'Identifier' || node.type === 'JSXIdentifier') {
    const result = node.name;
    if (optionalChains) {
      // Mark as required.
      optionalChains.set(result, false);
    }
    return result;
  } else if (node.type === 'MemberExpression' && !node.computed) {
    const object = analyzePropertyChain(node.object, optionalChains);
    const property = analyzePropertyChain(node.property, null);
    const result = `${object}.${property}`;
    markNode(node, optionalChains, result);
    return result;
  } else if (node.type === 'OptionalMemberExpression' && !node.computed) {
    const object = analyzePropertyChain(node.object, optionalChains);
    const property = analyzePropertyChain(node.property, null);
    const result = `${object}.${property}`;
    markNode(node, optionalChains, result);
    return result;
  } else if (
    node.type === 'ChainExpression' &&
    (!('computed' in node) || !node.computed)
  ) {
    const expression = node.expression;

    if (expression.type === 'CallExpression') {
      throw new Error(`Unsupported node type: ${expression.type}`);
    }

    const object = analyzePropertyChain(expression.object, optionalChains);
    const property = analyzePropertyChain(expression.property, null);
    const result = `${object}.${property}`;
    markNode(expression, optionalChains, result);
    return result;
  } else {
    throw new Error(`Unsupported node type: ${node.type}`);
  }
}

Domain

Subdomains

Calls

Frequently Asked Questions

What does analyzePropertyChain() do?
analyzePropertyChain() is a function in the react codebase, defined in packages/eslint-plugin-react-hooks/src/rules/ExhaustiveDeps.ts.
Where is analyzePropertyChain() defined?
analyzePropertyChain() is defined in packages/eslint-plugin-react-hooks/src/rules/ExhaustiveDeps.ts at line 1927.
What does analyzePropertyChain() call?
analyzePropertyChain() calls 1 function(s): markNode.
What calls analyzePropertyChain()?
analyzePropertyChain() is called by 2 function(s): getReactiveHookCallbackIndex, rule.create.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free