Home / File/ error.false-positive-useMemo-overlap-scopes.ts — react Source File

error.false-positive-useMemo-overlap-scopes.ts — react Source File

Architecture documentation for error.false-positive-useMemo-overlap-scopes.ts, a typescript file in the react codebase. 2 imports, 0 dependents.

File typescript TestingUtilities Fixtures 2 imports 1 functions

Entity Profile

Dependency Diagram

graph LR
  1302c8b7_4365_ef78_8faf_c17f9ef4f594["error.false-positive-useMemo-overlap-scopes.ts"]
  ac587885_e294_a1e9_b13f_5e7b920fdb42["react"]
  1302c8b7_4365_ef78_8faf_c17f9ef4f594 --> ac587885_e294_a1e9_b13f_5e7b920fdb42
  006eec3d_77a9_4a47_e6c1_a96d7a6c9c05["shared-runtime"]
  1302c8b7_4365_ef78_8faf_c17f9ef4f594 --> 006eec3d_77a9_4a47_e6c1_a96d7a6c9c05
  style 1302c8b7_4365_ef78_8faf_c17f9ef4f594 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

// @validatePreserveExistingMemoizationGuarantees:true
import {useMemo} from 'react';
import {arrayPush} from 'shared-runtime';

/**
 * Repro showing differences between mutable ranges and scope ranges.
 *
 * For useMemo dependency `x`:
 * - mutable range ends after the `arrayPush(x, b)` instruction
 * - scope range is extended due to MergeOverlappingScopes
 *
 * Since manual memo deps are guaranteed to be named (guaranteeing valid
 * codegen), it's correct to take a dependency on a dep *before* the end
 * of its scope (but after its mutable range ends).
 */

function useFoo(a, b) {
  const x = [];
  const y = [];
  arrayPush(x, b);
  const result = useMemo(() => {
    return [Math.max(x[1], a)];
  }, [a, x]);
  arrayPush(y, 3);
  return {result, y};
}

export const FIXTURE_ENTRYPOINT = {
  fn: useFoo,
  params: [1, 2],
};

Subdomains

Functions

Dependencies

  • react
  • shared-runtime

Frequently Asked Questions

What does error.false-positive-useMemo-overlap-scopes.ts do?
error.false-positive-useMemo-overlap-scopes.ts is a source file in the react codebase, written in typescript. It belongs to the TestingUtilities domain, Fixtures subdomain.
What functions are defined in error.false-positive-useMemo-overlap-scopes.ts?
error.false-positive-useMemo-overlap-scopes.ts defines 1 function(s): useFoo.
What does error.false-positive-useMemo-overlap-scopes.ts depend on?
error.false-positive-useMemo-overlap-scopes.ts imports 2 module(s): react, shared-runtime.
Where is error.false-positive-useMemo-overlap-scopes.ts in the architecture?
error.false-positive-useMemo-overlap-scopes.ts is located at compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/preserve-memo-validation/error.false-positive-useMemo-overlap-scopes.ts (domain: TestingUtilities, subdomain: Fixtures, directory: compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/preserve-memo-validation).

Analyze Your Own Codebase

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

Try Supermodel Free