Home / Function/ pushLoopContext() — react Function Reference

pushLoopContext() — react Function Reference

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

Entity Profile

Dependency Diagram

graph TD
  575dfda7_fd7d_2e7a_7b66_a9eefb7b5c2a["pushLoopContext()"]
  d3cee22c_5e2d_f853_c075_2c7c55e5d22c["CodePathState"]
  575dfda7_fd7d_2e7a_7b66_a9eefb7b5c2a -->|defined in| d3cee22c_5e2d_f853_c075_2c7c55e5d22c
  b619f50d_ffe6_93b8_b7a7_402d0cdecbc6["pushBreakContext()"]
  575dfda7_fd7d_2e7a_7b66_a9eefb7b5c2a -->|calls| b619f50d_ffe6_93b8_b7a7_402d0cdecbc6
  f6f7a515_92f3_1128_a333_ef52d2269bc9["pushChoiceContext()"]
  575dfda7_fd7d_2e7a_7b66_a9eefb7b5c2a -->|calls| f6f7a515_92f3_1128_a333_ef52d2269bc9
  style 575dfda7_fd7d_2e7a_7b66_a9eefb7b5c2a fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

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

  pushLoopContext(type, label) {
    const forkContext = this.forkContext;
    const breakContext = this.pushBreakContext(true, label);

    switch (type) {
      case 'WhileStatement':
        this.pushChoiceContext('loop', false);
        this.loopContext = {
          upper: this.loopContext,
          type,
          label,
          test: void 0,
          continueDestSegments: null,
          brokenForkContext: breakContext.brokenForkContext,
        };
        break;

      case 'DoWhileStatement':
        this.pushChoiceContext('loop', false);
        this.loopContext = {
          upper: this.loopContext,
          type,
          label,
          test: void 0,
          entrySegments: null,
          continueForkContext: ForkContext.newEmpty(forkContext),
          brokenForkContext: breakContext.brokenForkContext,
        };
        break;

      case 'ForStatement':
        this.pushChoiceContext('loop', false);
        this.loopContext = {
          upper: this.loopContext,
          type,
          label,
          test: void 0,
          endOfInitSegments: null,
          testSegments: null,
          endOfTestSegments: null,
          updateSegments: null,
          endOfUpdateSegments: null,
          continueDestSegments: null,
          brokenForkContext: breakContext.brokenForkContext,
        };
        break;

      case 'ForInStatement':
      case 'ForOfStatement':
        this.loopContext = {
          upper: this.loopContext,
          type,
          label,
          prevSegments: null,
          leftSegments: null,
          endOfLeftSegments: null,
          continueDestSegments: null,
          brokenForkContext: breakContext.brokenForkContext,
        };
        break;

      /* c8 ignore next */
      default:
        throw new Error(`unknown type: "${type}"`);
    }
  }

Domain

Subdomains

Frequently Asked Questions

What does pushLoopContext() do?
pushLoopContext() is a function in the react codebase, defined in packages/eslint-plugin-react-hooks/src/code-path-analysis/code-path-state.js.
Where is pushLoopContext() defined?
pushLoopContext() is defined in packages/eslint-plugin-react-hooks/src/code-path-analysis/code-path-state.js at line 955.
What does pushLoopContext() call?
pushLoopContext() calls 2 function(s): pushBreakContext, pushChoiceContext.

Analyze Your Own Codebase

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

Try Supermodel Free