Home / File/ nonmutating-capture-in-unsplittable-memo-block.ts — react Source File

nonmutating-capture-in-unsplittable-memo-block.ts — react Source File

Architecture documentation for nonmutating-capture-in-unsplittable-memo-block.ts, a typescript file in the react codebase. 1 imports, 0 dependents.

File typescript TestingUtilities Fixtures 1 imports 1 functions

Entity Profile

Dependency Diagram

graph LR
  0fb5df59_9b7d_e2cc_8870_6f68221bc7d9["nonmutating-capture-in-unsplittable-memo-block.ts"]
  006eec3d_77a9_4a47_e6c1_a96d7a6c9c05["shared-runtime"]
  0fb5df59_9b7d_e2cc_8870_6f68221bc7d9 --> 006eec3d_77a9_4a47_e6c1_a96d7a6c9c05
  style 0fb5df59_9b7d_e2cc_8870_6f68221bc7d9 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import {identity, mutate} from 'shared-runtime';

/**
 * Currently, InferReactiveScopeVariables do not ensure that maybe-aliased
 * values get assigned the same reactive scope. This is safe only when an
 * already-constructed value is captured, e.g.
 * ```js
 * const x = makeObj();  ⌝ mutable range of x
 * mutate(x);            ⌟
 *                       <-- after this point, we can produce a canonical version
 *                           of x for all following aliases
 * const y = [];
 * y.push(x);            <-- y captures x
 * ```
 *
 * However, if a value is captured/aliased during its mutable range and the
 * capturing container is separately memoized, it becomes difficult to guarantee
 * that all aliases refer to the same value.
 *
 */
function useFoo({a, b}) {
  const x = {a};
  const y = {};
  mutate(x);
  const z = [identity(y), b];
  mutate(y);

  if (z[0] !== y) {
    throw new Error('oh no!');
  }
  return z;
}

export const FIXTURE_ENTRYPOINT = {
  fn: useFoo,
  params: [{a: 2, b: 3}],
  sequentialRenders: [
    {a: 2, b: 3},
    {a: 4, b: 3},
  ],
};

Subdomains

Functions

Dependencies

  • shared-runtime

Frequently Asked Questions

What does nonmutating-capture-in-unsplittable-memo-block.ts do?
nonmutating-capture-in-unsplittable-memo-block.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 nonmutating-capture-in-unsplittable-memo-block.ts?
nonmutating-capture-in-unsplittable-memo-block.ts defines 1 function(s): useFoo.
What does nonmutating-capture-in-unsplittable-memo-block.ts depend on?
nonmutating-capture-in-unsplittable-memo-block.ts imports 1 module(s): shared-runtime.
Where is nonmutating-capture-in-unsplittable-memo-block.ts in the architecture?
nonmutating-capture-in-unsplittable-memo-block.ts is located at compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/nonmutating-capture-in-unsplittable-memo-block.ts (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