Home / File/ mixedreadonly-mutating-map.js — react Source File

mixedreadonly-mutating-map.js — react Source File

Architecture documentation for mixedreadonly-mutating-map.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
  081a4152_0641_908c_7b79_1753b589571f["mixedreadonly-mutating-map.js"]
  006eec3d_77a9_4a47_e6c1_a96d7a6c9c05["shared-runtime"]
  081a4152_0641_908c_7b79_1753b589571f --> 006eec3d_77a9_4a47_e6c1_a96d7a6c9c05
  style 081a4152_0641_908c_7b79_1753b589571f fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import {
  arrayPush,
  identity,
  makeArray,
  Stringify,
  useFragment,
} from 'shared-runtime';

/**
 * Bug repro showing why it's invalid for function references to be annotated
 * with a `Read` effect when that reference might lead to the function being
 * invoked.
 *
 * Note that currently, `Array.map` is annotated to have `Read` effects on its
 * operands. This is incorrect as function effects must be replayed when `map`
 * is called
 * - Read:                non-aliasing data dependency
 * - Capture:             maybe-aliasing data dependency
 * - ConditionallyMutate: maybe-aliasing data dependency; maybe-write / invoke
 *     but only if the value is mutable
 *
 * Invalid evaluator result: Found differences in evaluator results Non-forget
 * (expected): (kind: ok)
 *   <div>{"x":[2,2,2],"count":3}</div><div>{"item":1}</div>
 *   <div>{"x":[2,2,2],"count":4}</div><div>{"item":1}</div>
 * Forget:
 *   (kind: ok)
 *   <div>{"x":[2,2,2],"count":3}</div><div>{"item":1}</div>
 *   <div>{"x":[2,2,2,2,2,2],"count":4}</div><div>{"item":1}</div>
 */

function Component({extraJsx}) {
  const x = makeArray();
  const items = useFragment();
  // This closure has the following effects that must be replayed:
  //   - MaybeFreeze / Capture of `items`
  //   - ConditionalMutate of x
  const jsx = items.a.map((item, i) => {
    arrayPush(x, 2);
    return <Stringify item={item} key={i} />;
  });
  const offset = jsx.length;
  for (let i = 0; i < extraJsx; i++) {
    jsx.push(<Stringify item={0} key={i + offset} />);
  }
  const count = jsx.length;
  identity(count);
  return (
    <>
      <Stringify x={x} count={count} />
      {jsx[0]}
    </>
  );
}
export const FIXTURE_ENTRYPOINT = {
  fn: Component,
  params: [{extraJsx: 0}],
  sequentialRenders: [{extraJsx: 0}, {extraJsx: 1}],
};

Subdomains

Functions

Dependencies

  • shared-runtime

Frequently Asked Questions

What does mixedreadonly-mutating-map.js do?
mixedreadonly-mutating-map.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 mixedreadonly-mutating-map.js?
mixedreadonly-mutating-map.js defines 1 function(s): Component.
What does mixedreadonly-mutating-map.js depend on?
mixedreadonly-mutating-map.js imports 1 module(s): shared-runtime.
Where is mixedreadonly-mutating-map.js in the architecture?
mixedreadonly-mutating-map.js is located at compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/mixedreadonly-mutating-map.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