Home / Function/ postprocess() — react Function Reference

postprocess() — react Function Reference

Architecture documentation for the postprocess() function in code-path-analyzer.js from the react codebase.

Entity Profile

Dependency Diagram

graph TD
  11e4f269_d571_4dd5_501c_3de51f1f8ba6["postprocess()"]
  09a1c78a_21af_9be8_1cc6_22cf0ceb9f8f["code-path-analyzer.js"]
  11e4f269_d571_4dd5_501c_3de51f1f8ba6 -->|defined in| 09a1c78a_21af_9be8_1cc6_22cf0ceb9f8f
  dc411858_ea9d_ab2f_49db_a3428829fbde["leaveNode()"]
  dc411858_ea9d_ab2f_49db_a3428829fbde -->|calls| 11e4f269_d571_4dd5_501c_3de51f1f8ba6
  fa3487f5_3f61_87df_62c2_fe89baf54f24["leaveFromCurrentSegment()"]
  11e4f269_d571_4dd5_501c_3de51f1f8ba6 -->|calls| fa3487f5_3f61_87df_62c2_fe89baf54f24
  e0bbc1ce_8e9f_12d8_263b_769599e99847["isPropertyDefinitionValue()"]
  11e4f269_d571_4dd5_501c_3de51f1f8ba6 -->|calls| e0bbc1ce_8e9f_12d8_263b_769599e99847
  style 11e4f269_d571_4dd5_501c_3de51f1f8ba6 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/eslint-plugin-react-hooks/src/code-path-analysis/code-path-analyzer.js lines 650–713

function postprocess(analyzer, node) {
  /**
   * Ends the code path for the current node.
   * @returns {void}
   */
  function endCodePath() {
    let codePath = analyzer.codePath;

    // Mark the current path as the final node.
    CodePath.getState(codePath).makeFinal();

    // Emits onCodePathSegmentEnd event of the current segments.
    leaveFromCurrentSegment(analyzer, node);

    // Emits onCodePathEnd event of this code path.
    analyzer.emitter.emit('onCodePathEnd', codePath, node);

    codePath = analyzer.codePath = analyzer.codePath.upper;
  }

  switch (node.type) {
    case 'Program':
    case 'FunctionDeclaration':
    case 'ComponentDeclaration':
    case 'HookDeclaration':
    case 'FunctionExpression':
    case 'ArrowFunctionExpression':
    case 'StaticBlock': {
      endCodePath();
      break;
    }

    // The `arguments.length >= 1` case is in `preprocess` function.
    case 'CallExpression':
      if (node.optional === true && node.arguments.length === 0) {
        CodePath.getState(analyzer.codePath).makeOptionalRight();
      }
      break;

    default:
      break;
  }

  /*
   * Special case: The right side of class field initializer is considered
   * to be its own function, so we need to end a code path in this
   * case.
   *
   * We need to check after the other checks in order to close the
   * code paths in the correct order for code like this:
   *
   *
   * class Foo {
   *     a = () => {}
   * }
   *
   * In this case, The ArrowFunctionExpression code path is closed first
   * and then we need to close the code path for the PropertyDefinition
   * value.
   */
  if (isPropertyDefinitionValue(node)) {
    endCodePath();
  }
}

Domain

Subdomains

Called By

Frequently Asked Questions

What does postprocess() do?
postprocess() is a function in the react codebase, defined in packages/eslint-plugin-react-hooks/src/code-path-analysis/code-path-analyzer.js.
Where is postprocess() defined?
postprocess() is defined in packages/eslint-plugin-react-hooks/src/code-path-analysis/code-path-analyzer.js at line 650.
What does postprocess() call?
postprocess() calls 2 function(s): isPropertyDefinitionValue, leaveFromCurrentSegment.
What calls postprocess()?
postprocess() is called by 1 function(s): leaveNode.

Analyze Your Own Codebase

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

Try Supermodel Free