Home / File/ useCallback-captures-reassigned-context-property.tsx — react Source File

useCallback-captures-reassigned-context-property.tsx — react Source File

Architecture documentation for useCallback-captures-reassigned-context-property.tsx, a tsx file in the react codebase. 2 imports, 0 dependents.

File tsx CompilerCore BabelIntegration 2 imports 1 functions

Entity Profile

Dependency Diagram

graph LR
  475c81d2_4e8d_339e_7eb9_d383d72c5188["useCallback-captures-reassigned-context-property.tsx"]
  c745ba00_63aa_6e9b_0885_a745bade6cf7["react"]
  475c81d2_4e8d_339e_7eb9_d383d72c5188 --> c745ba00_63aa_6e9b_0885_a745bade6cf7
  9b88626e_0355_91af_db84_89f44a65ebc6["shared-runtime"]
  475c81d2_4e8d_339e_7eb9_d383d72c5188 --> 9b88626e_0355_91af_db84_89f44a65ebc6
  style 475c81d2_4e8d_339e_7eb9_d383d72c5188 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

// @validatePreserveExistingMemoizationGuarantees
import {useCallback} from 'react';
import {Stringify} from 'shared-runtime';

/**
 * TODO: we're currently bailing out because `contextVar` is a context variable
 * and not recorded into the PropagateScopeDeps LoadLocal / PropertyLoad
 * sidemap. Previously, we were able to avoid this as `BuildHIR` hoisted
 * `LoadContext` and `PropertyLoad` instructions into the outer function, which
 * we took as eligible dependencies.
 *
 * One solution is to simply record `LoadContext` identifiers into the
 * temporaries sidemap when the instruction occurs *after* the context
 * variable's mutable range.
 */
function Foo(props) {
  let contextVar;
  if (props.cond) {
    contextVar = {val: 2};
  } else {
    contextVar = {};
  }

  const cb = useCallback(() => [contextVar.val], [contextVar.val]);

  return <Stringify cb={cb} shouldInvokeFns={true} />;
}

export const FIXTURE_ENTRYPOINT = {
  fn: Foo,
  params: [{cond: true}],
};

Domain

Subdomains

Functions

Dependencies

  • react
  • shared-runtime

Frequently Asked Questions

What does useCallback-captures-reassigned-context-property.tsx do?
useCallback-captures-reassigned-context-property.tsx is a source file in the react codebase, written in tsx. It belongs to the CompilerCore domain, BabelIntegration subdomain.
What functions are defined in useCallback-captures-reassigned-context-property.tsx?
useCallback-captures-reassigned-context-property.tsx defines 1 function(s): Foo.
What does useCallback-captures-reassigned-context-property.tsx depend on?
useCallback-captures-reassigned-context-property.tsx imports 2 module(s): react, shared-runtime.
Where is useCallback-captures-reassigned-context-property.tsx in the architecture?
useCallback-captures-reassigned-context-property.tsx is located at compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/preserve-memo-validation/useCallback-captures-reassigned-context-property.tsx (domain: CompilerCore, subdomain: BabelIntegration, directory: compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/preserve-memo-validation).

Analyze Your Own Codebase

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

Try Supermodel Free