Home / Function/ maybeRecordSetState() — react Function Reference

maybeRecordSetState() — react Function Reference

Architecture documentation for the maybeRecordSetState() function in ValidateNoDerivedComputationsInEffects_exp.ts from the react codebase.

Entity Profile

Dependency Diagram

graph TD
  d206b1f3_3227_c6ab_9a06_aa3ed56d36cf["maybeRecordSetState()"]
  a38a9d1f_969c_8056_aa80_6cb5fedba226["ValidateNoDerivedComputationsInEffects_exp.ts"]
  d206b1f3_3227_c6ab_9a06_aa3ed56d36cf -->|defined in| a38a9d1f_969c_8056_aa80_6cb5fedba226
  23e95905_7740_9185_1ad6_1a529d6f88ad["recordInstructionDerivations()"]
  23e95905_7740_9185_1ad6_1a529d6f88ad -->|calls| d206b1f3_3227_c6ab_9a06_aa3ed56d36cf
  8014ef2c_7e1b_b1da_b888_615d609f3c01["validateEffect()"]
  8014ef2c_7e1b_b1da_b888_615d609f3c01 -->|calls| d206b1f3_3227_c6ab_9a06_aa3ed56d36cf
  10043bf1_f7ee_9ed9_307a_fe3edfd02b09["eachInstructionLValue()"]
  d206b1f3_3227_c6ab_9a06_aa3ed56d36cf -->|calls| 10043bf1_f7ee_9ed9_307a_fe3edfd02b09
  58133747_182e_d838_f59c_07fbac51ed59["getRootSetState()"]
  d206b1f3_3227_c6ab_9a06_aa3ed56d36cf -->|calls| 58133747_182e_d838_f59c_07fbac51ed59
  style d206b1f3_3227_c6ab_9a06_aa3ed56d36cf fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

compiler/packages/babel-plugin-react-compiler/src/Validation/ValidateNoDerivedComputationsInEffects_exp.ts lines 322–345

function maybeRecordSetState(
  instr: Instruction,
  loads: Map<IdentifierId, IdentifierId | null>,
  usages: Map<IdentifierId, Set<SourceLocation>>,
): void {
  for (const operand of eachInstructionLValue(instr)) {
    if (
      instr.value.kind === 'LoadLocal' &&
      loads.has(instr.value.place.identifier.id)
    ) {
      loads.set(operand.identifier.id, instr.value.place.identifier.id);
    } else {
      if (isSetStateType(operand.identifier)) {
        // this is a root setState
        loads.set(operand.identifier.id, null);
      }
    }

    const rootSetState = getRootSetState(operand.identifier.id, loads);
    if (rootSetState !== null && usages.get(rootSetState) === undefined) {
      usages.set(rootSetState, new Set([operand.loc]));
    }
  }
}

Domain

Subdomains

Frequently Asked Questions

What does maybeRecordSetState() do?
maybeRecordSetState() is a function in the react codebase, defined in compiler/packages/babel-plugin-react-compiler/src/Validation/ValidateNoDerivedComputationsInEffects_exp.ts.
Where is maybeRecordSetState() defined?
maybeRecordSetState() is defined in compiler/packages/babel-plugin-react-compiler/src/Validation/ValidateNoDerivedComputationsInEffects_exp.ts at line 322.
What does maybeRecordSetState() call?
maybeRecordSetState() calls 2 function(s): eachInstructionLValue, getRootSetState.
What calls maybeRecordSetState()?
maybeRecordSetState() is called by 2 function(s): recordInstructionDerivations, validateEffect.

Analyze Your Own Codebase

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

Try Supermodel Free