Home / Function/ makeForBody() — react Function Reference

makeForBody() — react Function Reference

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

Entity Profile

Dependency Diagram

graph TD
  7dfff945_2de0_14ee_52c3_45df02bdd036["makeForBody()"]
  d3cee22c_5e2d_f853_c075_2c7c55e5d22c["CodePathState"]
  7dfff945_2de0_14ee_52c3_45df02bdd036 -->|defined in| d3cee22c_5e2d_f853_c075_2c7c55e5d22c
  340594f4_b9ab_167e_55a5_90de76787b13["makeLooped()"]
  7dfff945_2de0_14ee_52c3_45df02bdd036 -->|calls| 340594f4_b9ab_167e_55a5_90de76787b13
  9b61c605_e800_3e20_0964_f24f896ebf43["finalizeTestSegmentsOfFor()"]
  7dfff945_2de0_14ee_52c3_45df02bdd036 -->|calls| 9b61c605_e800_3e20_0964_f24f896ebf43
  style 7dfff945_2de0_14ee_52c3_45df02bdd036 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

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

  makeForBody() {
    const context = this.loopContext;
    const choiceContext = this.choiceContext;
    const forkContext = this.forkContext;

    // Update state.
    if (context.updateSegments) {
      context.endOfUpdateSegments = forkContext.head;

      // `update` -> `test`
      if (context.testSegments) {
        makeLooped(this, context.endOfUpdateSegments, context.testSegments);
      }
    } else if (context.testSegments) {
      finalizeTestSegmentsOfFor(context, choiceContext, forkContext.head);
    } else {
      context.endOfInitSegments = forkContext.head;
    }

    let bodySegments = context.endOfTestSegments;

    if (!bodySegments) {
      /*
       * If there is not the `test` part, the `body` path comes from the
       * `init` part and the `update` part.
       */
      const prevForkContext = ForkContext.newEmpty(forkContext);

      prevForkContext.add(context.endOfInitSegments);
      if (context.endOfUpdateSegments) {
        prevForkContext.add(context.endOfUpdateSegments);
      }

      bodySegments = prevForkContext.makeNext(0, -1);
    }
    context.continueDestSegments = context.continueDestSegments || bodySegments;
    forkContext.replaceHead(bodySegments);
  }

Domain

Subdomains

Frequently Asked Questions

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

Analyze Your Own Codebase

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

Try Supermodel Free