Home / File/ early-return-no-declarations-reassignments-dependencies.js — react Source File

early-return-no-declarations-reassignments-dependencies.js — react Source File

Architecture documentation for early-return-no-declarations-reassignments-dependencies.js, a javascript file in the react codebase. 1 imports, 0 dependents.

File javascript TestingUtilities Fixtures 1 imports 1 functions

Entity Profile

Dependency Diagram

graph LR
  58b82633_0dab_aec7_3027_ca415d7ae2f2["early-return-no-declarations-reassignments-dependencies.js"]
  006eec3d_77a9_4a47_e6c1_a96d7a6c9c05["shared-runtime"]
  58b82633_0dab_aec7_3027_ca415d7ae2f2 --> 006eec3d_77a9_4a47_e6c1_a96d7a6c9c05
  style 58b82633_0dab_aec7_3027_ca415d7ae2f2 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import {makeArray} from 'shared-runtime';

/**
 * This fixture tests what happens when a reactive has no declarations (other than an early return),
 * no reassignments, and no dependencies. In this case the only thing we can use to decide if we
 * should take the if or else branch is the early return declaration. But if that uses the same
 * sentinel as the memo cache sentinel, then if the previous execution did not early return it will
 * look like we didn't execute the memo block yet, and we'll needlessly re-execute instead of skipping
 * to the else branch.
 *
 * We have to use a distinct sentinel for the early return value.
 *
 * Here the fixture will always take the "else" branch and never early return. Logging (not included)
 * confirms that the scope for `x` only executes once, on the first render of the component.
 */
let ENABLE_FEATURE = false;

function Component(props) {
  let x = [];
  if (ENABLE_FEATURE) {
    x.push(42);
    return x;
  } else {
    console.log('fallthrough');
  }
  return makeArray(props.a);
}

export const FIXTURE_ENTRYPOINT = {
  fn: Component,
  params: [],
  sequentialRenders: [
    {a: 42},
    {a: 42},
    {a: 3.14},
    {a: 3.14},
    {a: 42},
    {a: 3.14},
    {a: 42},
    {a: 3.14},
  ],
};

Subdomains

Functions

Dependencies

  • shared-runtime

Frequently Asked Questions

What does early-return-no-declarations-reassignments-dependencies.js do?
early-return-no-declarations-reassignments-dependencies.js is a source file in the react codebase, written in javascript. It belongs to the TestingUtilities domain, Fixtures subdomain.
What functions are defined in early-return-no-declarations-reassignments-dependencies.js?
early-return-no-declarations-reassignments-dependencies.js defines 1 function(s): Component.
What does early-return-no-declarations-reassignments-dependencies.js depend on?
early-return-no-declarations-reassignments-dependencies.js imports 1 module(s): shared-runtime.
Where is early-return-no-declarations-reassignments-dependencies.js in the architecture?
early-return-no-declarations-reassignments-dependencies.js is located at compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/early-return-no-declarations-reassignments-dependencies.js (domain: TestingUtilities, subdomain: Fixtures, directory: compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler).

Analyze Your Own Codebase

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

Try Supermodel Free