Home / File/ allow-mutate-global-in-effect-fixpoint.js — react Source File

allow-mutate-global-in-effect-fixpoint.js — react Source File

Architecture documentation for allow-mutate-global-in-effect-fixpoint.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
  b8e968d0_4fad_b5c9_b29b_2c80f4e7880b["allow-mutate-global-in-effect-fixpoint.js"]
  ac587885_e294_a1e9_b13f_5e7b920fdb42["react"]
  b8e968d0_4fad_b5c9_b29b_2c80f4e7880b --> ac587885_e294_a1e9_b13f_5e7b920fdb42
  style b8e968d0_4fad_b5c9_b29b_2c80f4e7880b fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import {useEffect, useState} from 'react';

let someGlobal = {value: null};

function Component() {
  const [state, setState] = useState(someGlobal);

  // NOTE: if we initialize to eg null or a local, then it won't be a definitively global
  // mutation below when we modify `y`. The point of this is example is that if all control
  // flow paths produce a global, we allow the mutation in an effect
  let x = someGlobal;
  while (x == null) {
    x = someGlobal;
  }

  // capture into a separate variable that is not a context variable.
  const y = x;
  /**
   * Note that this fixture currently produces a stale effect closure if `y = x
   * = someGlobal` changes between renders. Under current compiler assumptions,
   * that would be a rule of react violation.
   */
  useEffect(() => {
    y.value = 'hello';
  });

  useEffect(() => {
    setState(someGlobal.value);
  }, [someGlobal]);

  return <div>{String(state)}</div>;
}

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

Subdomains

Functions

Dependencies

  • react

Frequently Asked Questions

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