Home / Function/ popTryContext() — react Function Reference

popTryContext() — react Function Reference

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

Entity Profile

Dependency Diagram

graph TD
  fdc317a5_31e7_89af_23f5_c54520226a3f["popTryContext()"]
  d3cee22c_5e2d_f853_c075_2c7c55e5d22c["CodePathState"]
  fdc317a5_31e7_89af_23f5_c54520226a3f -->|defined in| d3cee22c_5e2d_f853_c075_2c7c55e5d22c
  4581c407_1b84_6f80_c60d_80725b7a3917["popForkContext()"]
  fdc317a5_31e7_89af_23f5_c54520226a3f -->|calls| 4581c407_1b84_6f80_c60d_80725b7a3917
  21db5fcc_9cef_b52f_8f79_acd74ad92218["getReturnContext()"]
  fdc317a5_31e7_89af_23f5_c54520226a3f -->|calls| 21db5fcc_9cef_b52f_8f79_acd74ad92218
  d986cf23_ac32_702c_8619_6a4499c7dba5["getThrowContext()"]
  fdc317a5_31e7_89af_23f5_c54520226a3f -->|calls| d986cf23_ac32_702c_8619_6a4499c7dba5
  style fdc317a5_31e7_89af_23f5_c54520226a3f fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

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

  popTryContext() {
    const context = this.tryContext;

    this.tryContext = context.upper;

    if (context.position === 'catch') {
      // Merges two paths from the `try` block and `catch` block merely.
      this.popForkContext();
      return;
    }

    /*
     * The following process is executed only when there is the `finally`
     * block.
     */

    const returned = context.returnedForkContext;
    const thrown = context.thrownForkContext;

    if (returned.empty && thrown.empty) {
      return;
    }

    // Separate head to normal paths and leaving paths.
    const headSegments = this.forkContext.head;

    this.forkContext = this.forkContext.upper;
    const normalSegments = headSegments.slice(0, (headSegments.length / 2) | 0);
    const leavingSegments = headSegments.slice((headSegments.length / 2) | 0);

    // Forwards the leaving path to upper contexts.
    if (!returned.empty) {
      getReturnContext(this).returnedForkContext.add(leavingSegments);
    }
    if (!thrown.empty) {
      getThrowContext(this).thrownForkContext.add(leavingSegments);
    }

    // Sets the normal path as the next.
    this.forkContext.replaceHead(normalSegments);

    /*
     * If both paths of the `try` block and the `catch` block are
     * unreachable, the next path becomes unreachable as well.
     */
    if (!context.lastOfTryIsReachable && !context.lastOfCatchIsReachable) {
      this.forkContext.makeUnreachable();
    }
  }

Domain

Subdomains

Frequently Asked Questions

What does popTryContext() do?
popTryContext() is a function in the react codebase, defined in packages/eslint-plugin-react-hooks/src/code-path-analysis/code-path-state.js.
Where is popTryContext() defined?
popTryContext() is defined in packages/eslint-plugin-react-hooks/src/code-path-analysis/code-path-state.js at line 782.
What does popTryContext() call?
popTryContext() calls 3 function(s): getReturnContext, getThrowContext, popForkContext.

Analyze Your Own Codebase

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

Try Supermodel Free