Home / Type/ Effect Type — react Architecture

Effect Type — react Architecture

Architecture documentation for the Effect type/interface in HIR.ts from the react codebase.

Entity Profile

Dependency Diagram

graph TD
  60d25db4_8803_db04_13e8_2251272ec589["Effect"]
  18a78965_f593_105b_e5e8_07001321c2ec["HIR.ts"]
  60d25db4_8803_db04_13e8_2251272ec589 -->|defined in| 18a78965_f593_105b_e5e8_07001321c2ec
  style 60d25db4_8803_db04_13e8_2251272ec589 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

compiler/packages/babel-plugin-react-compiler/src/HIR/HIR.ts lines 1511–1538

export enum Effect {
  // Default value: not allowed after lifetime inference
  Unknown = '<unknown>',
  // This reference freezes the value (corresponds to a place where codegen should emit a freeze instruction)
  Freeze = 'freeze',
  // This reference reads the value
  Read = 'read',
  // This reference reads and stores the value
  Capture = 'capture',
  ConditionallyMutateIterator = 'mutate-iterator?',
  /*
   * This reference *may* write to (mutate) the value. This covers two similar cases:
   * - The compiler is being conservative and assuming that a value *may* be mutated
   * - The effect is polymorphic: mutable values may be mutated, non-mutable values
   *   will not be mutated.
   * In both cases, we conservatively assume that mutable values will be mutated.
   * But we do not error if the value is known to be immutable.
   */
  ConditionallyMutate = 'mutate?',

  /*
   * This reference *does* write to (mutate) the value. It is an error (invalid input)
   * if an immutable value flows into a location with this effect.
   */
  Mutate = 'mutate',
  // This reference may alias to (mutate) the value
  Store = 'store',
}

Frequently Asked Questions

What is the Effect type?
Effect is a type/interface in the react codebase, defined in compiler/packages/babel-plugin-react-compiler/src/HIR/HIR.ts.
Where is Effect defined?
Effect is defined in compiler/packages/babel-plugin-react-compiler/src/HIR/HIR.ts at line 1511.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free