Home / File/ repro-returned-inner-fn-mutates-context.js — react Source File

repro-returned-inner-fn-mutates-context.js — react Source File

Architecture documentation for repro-returned-inner-fn-mutates-context.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
  db856285_ec18_29a8_8003_6e0ffc12944b["repro-returned-inner-fn-mutates-context.js"]
  006eec3d_77a9_4a47_e6c1_a96d7a6c9c05["shared-runtime"]
  db856285_ec18_29a8_8003_6e0ffc12944b --> 006eec3d_77a9_4a47_e6c1_a96d7a6c9c05
  style db856285_ec18_29a8_8003_6e0ffc12944b fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import {Stringify} from 'shared-runtime';

/**
 * Example showing that returned inner function expressions should not be
 * typed with `freeze` effects.
 */
function Foo({a, b}) {
  'use memo';
  const obj = {};
  const updaterFactory = () => {
    /**
     * This returned function expression *is* a local value. But it might (1)
     * capture and mutate its context environment and (2) be called during
     * render.
     * Typing it with `freeze` effects would be incorrect as it would mean
     * inferring that calls to updaterFactory()() do not mutate its captured
     * context.
     */
    return newValue => {
      obj.value = newValue;
      obj.a = a;
    };
  };

  const updater = updaterFactory();
  updater(b);
  return <Stringify cb={obj} shouldInvokeFns={true} />;
}

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

Subdomains

Functions

Dependencies

  • shared-runtime

Frequently Asked Questions

What does repro-returned-inner-fn-mutates-context.js do?
repro-returned-inner-fn-mutates-context.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 repro-returned-inner-fn-mutates-context.js?
repro-returned-inner-fn-mutates-context.js defines 1 function(s): Foo.
What does repro-returned-inner-fn-mutates-context.js depend on?
repro-returned-inner-fn-mutates-context.js imports 1 module(s): shared-runtime.
Where is repro-returned-inner-fn-mutates-context.js in the architecture?
repro-returned-inner-fn-mutates-context.js is located at compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/repro-returned-inner-fn-mutates-context.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