Home / Function/ popLoopContext() — react Function Reference

popLoopContext() — react Function Reference

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

Entity Profile

Dependency Diagram

graph TD
  941f950b_cd48_1b4b_82f0_a7c8f79c78b6["popLoopContext()"]
  d3cee22c_5e2d_f853_c075_2c7c55e5d22c["CodePathState"]
  941f950b_cd48_1b4b_82f0_a7c8f79c78b6 -->|defined in| d3cee22c_5e2d_f853_c075_2c7c55e5d22c
  5da27dd3_9948_dd4b_f283_32a2cdeec34e["popChoiceContext()"]
  5da27dd3_9948_dd4b_f283_32a2cdeec34e -->|calls| 941f950b_cd48_1b4b_82f0_a7c8f79c78b6
  eaeeec6b_36c1_6d87_b602_172b094af25b["popBreakContext()"]
  941f950b_cd48_1b4b_82f0_a7c8f79c78b6 -->|calls| eaeeec6b_36c1_6d87_b602_172b094af25b
  5da27dd3_9948_dd4b_f283_32a2cdeec34e["popChoiceContext()"]
  941f950b_cd48_1b4b_82f0_a7c8f79c78b6 -->|calls| 5da27dd3_9948_dd4b_f283_32a2cdeec34e
  340594f4_b9ab_167e_55a5_90de76787b13["makeLooped()"]
  941f950b_cd48_1b4b_82f0_a7c8f79c78b6 -->|calls| 340594f4_b9ab_167e_55a5_90de76787b13
  style 941f950b_cd48_1b4b_82f0_a7c8f79c78b6 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/eslint-plugin-react-hooks/src/code-path-analysis/code-path-state.js lines 1027–1080

  popLoopContext() {
    const context = this.loopContext;

    this.loopContext = context.upper;

    const forkContext = this.forkContext;
    const brokenForkContext = this.popBreakContext().brokenForkContext;

    // Creates a looped path.
    switch (context.type) {
      case 'WhileStatement':
      case 'ForStatement':
        this.popChoiceContext();
        makeLooped(this, forkContext.head, context.continueDestSegments);
        break;

      case 'DoWhileStatement': {
        const choiceContext = this.popChoiceContext();

        if (!choiceContext.processed) {
          choiceContext.trueForkContext.add(forkContext.head);
          choiceContext.falseForkContext.add(forkContext.head);
        }
        if (context.test !== true) {
          brokenForkContext.addAll(choiceContext.falseForkContext);
        }

        // `true` paths go to looping.
        const segmentsList = choiceContext.trueForkContext.segmentsList;

        for (let i = 0; i < segmentsList.length; ++i) {
          makeLooped(this, segmentsList[i], context.entrySegments);
        }
        break;
      }

      case 'ForInStatement':
      case 'ForOfStatement':
        brokenForkContext.add(forkContext.head);
        makeLooped(this, forkContext.head, context.leftSegments);
        break;

      /* c8 ignore next */
      default:
        throw new Error('unreachable');
    }

    // Go next.
    if (brokenForkContext.empty) {
      forkContext.replaceHead(forkContext.makeUnreachable(-1, -1));
    } else {
      forkContext.replaceHead(brokenForkContext.makeNext(0, -1));
    }
  }

Domain

Subdomains

Called By

Frequently Asked Questions

What does popLoopContext() do?
popLoopContext() is a function in the react codebase, defined in packages/eslint-plugin-react-hooks/src/code-path-analysis/code-path-state.js.
Where is popLoopContext() defined?
popLoopContext() is defined in packages/eslint-plugin-react-hooks/src/code-path-analysis/code-path-state.js at line 1027.
What does popLoopContext() call?
popLoopContext() calls 3 function(s): makeLooped, popBreakContext, popChoiceContext.
What calls popLoopContext()?
popLoopContext() is called by 1 function(s): popChoiceContext.

Analyze Your Own Codebase

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

Try Supermodel Free