Home / Function/ getBreakTarget() — react Function Reference

getBreakTarget() — react Function Reference

Architecture documentation for the getBreakTarget() function in BuildReactiveFunction.ts from the react codebase.

Entity Profile

Dependency Diagram

graph TD
  c9d5ef77_d0cd_11c8_8414_09d6d6ce703e["getBreakTarget()"]
  4f68940d_e29b_1b55_8b23_bd29e8900efa["Context"]
  c9d5ef77_d0cd_11c8_8414_09d6d6ce703e -->|defined in| 4f68940d_e29b_1b55_8b23_bd29e8900efa
  f1ad8882_f4aa_8bed_3eb6_757cd4990fab["visitBreak()"]
  f1ad8882_f4aa_8bed_3eb6_757cd4990fab -->|calls| c9d5ef77_d0cd_11c8_8414_09d6d6ce703e
  041ca752_10c1_3cda_1f5c_02f44a01310e["invariant()"]
  c9d5ef77_d0cd_11c8_8414_09d6d6ce703e -->|calls| 041ca752_10c1_3cda_1f5c_02f44a01310e
  style c9d5ef77_d0cd_11c8_8414_09d6d6ce703e fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

compiler/packages/babel-plugin-react-compiler/src/ReactiveScopes/BuildReactiveFunction.ts lines 1384–1421

  getBreakTarget(block: BlockId): {
    block: BlockId;
    type: ReactiveTerminalTargetKind;
  } {
    let hasPrecedingLoop = false;
    for (let i = this.#controlFlowStack.length - 1; i >= 0; i--) {
      const target = this.#controlFlowStack[i]!;
      if (target.block === block) {
        let type: ReactiveTerminalTargetKind;
        if (target.type === 'loop') {
          /*
           * breaking out of a loop requires an explicit break,
           * but only requires a label if breaking past the innermost loop.
           */
          type = hasPrecedingLoop ? 'labeled' : 'unlabeled';
        } else if (i === this.#controlFlowStack.length - 1) {
          /*
           * breaking to the last break point, which is where control will transfer
           * implicitly
           */
          type = 'implicit';
        } else {
          // breaking somewhere else requires an explicit break
          type = 'labeled';
        }
        return {
          block: target.block,
          type,
        };
      }
      hasPrecedingLoop ||= target.type === 'loop';
    }

    CompilerError.invariant(false, {
      reason: 'Expected a break target',
      loc: GeneratedSource,
    });
  }

Domain

Subdomains

Calls

Called By

Frequently Asked Questions

What does getBreakTarget() do?
getBreakTarget() is a function in the react codebase, defined in compiler/packages/babel-plugin-react-compiler/src/ReactiveScopes/BuildReactiveFunction.ts.
Where is getBreakTarget() defined?
getBreakTarget() is defined in compiler/packages/babel-plugin-react-compiler/src/ReactiveScopes/BuildReactiveFunction.ts at line 1384.
What does getBreakTarget() call?
getBreakTarget() calls 1 function(s): invariant.
What calls getBreakTarget()?
getBreakTarget() is called by 1 function(s): visitBreak.

Analyze Your Own Codebase

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

Try Supermodel Free