Home / File/ mutable-lifetime-with-aliasing.js — react Source File

mutable-lifetime-with-aliasing.js — react Source File

Architecture documentation for mutable-lifetime-with-aliasing.js, a javascript file in the react codebase.

Entity Profile

Relationship Graph

Source Code

function mutate(x, y) {
  'use no forget';
  if (!Array.isArray(x.value)) {
    x.value = [];
  }
  x.value.push(y);
  if (y != null) {
    y.value = x;
  }
}

function Component(props) {
  const a = {};
  const b = [a]; // array elements alias
  const c = {};
  const d = {c}; // object values alias

  // capture all the values into this object
  const x = {};
  x.b = b;
  const y = mutate(x, d); // mutation aliases the arg and return value

  // all of these tests are seemingly readonly, since the values are never directly
  // mutated again. but they are all aliased by `x`, which is later modified, and
  // these are therefore mutable references:
  if (a) {
  }
  if (b) {
  }
  if (c) {
  }
  if (d) {
  }
  if (y) {
  }

  // could in theory mutate any of a/b/c/x/z, so the above should be inferred as mutable
  mutate(x, null);
  return x;
}

export const FIXTURE_ENTRYPOINT = {
  fn: Component,
  params: [{}],
  isComponent: false,
};

Subdomains

Frequently Asked Questions

What does mutable-lifetime-with-aliasing.js do?
mutable-lifetime-with-aliasing.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 mutable-lifetime-with-aliasing.js?
mutable-lifetime-with-aliasing.js defines 2 function(s): Component, mutate.
Where is mutable-lifetime-with-aliasing.js in the architecture?
mutable-lifetime-with-aliasing.js is located at compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/mutable-lifetime-with-aliasing.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