Home / File/ allow-ref-access-in-unused-callback-nested.js — react Source File

allow-ref-access-in-unused-callback-nested.js — react Source File

Architecture documentation for allow-ref-access-in-unused-callback-nested.js, a javascript file in the react codebase. 1 imports, 0 dependents.

File javascript TestingUtilities Fixtures 1 imports 2 functions

Entity Profile

Dependency Diagram

graph LR
  a8c0b5dc_65f4_b7e1_7ac9_a0b7f993cd8a["allow-ref-access-in-unused-callback-nested.js"]
  ac587885_e294_a1e9_b13f_5e7b920fdb42["react"]
  a8c0b5dc_65f4_b7e1_7ac9_a0b7f993cd8a --> ac587885_e294_a1e9_b13f_5e7b920fdb42
  style a8c0b5dc_65f4_b7e1_7ac9_a0b7f993cd8a fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

// @validateRefAccessDuringRender
import {useEffect, useRef, useState} from 'react';

function Component() {
  const ref = useRef(null);
  const [state, setState] = useState(false);
  useEffect(() => {
    const callback = () => {
      ref.current = 'Ok';
    };
  }, []);

  useEffect(() => {
    setState(true);
  }, []);

  // We use state to force a re-render and observe whether the
  // ref updated. This lets us check that the effect actually ran
  // and wasn't DCE'd
  return <Child key={String(state)} ref={ref} />;
}

function Child({ref}) {
  'use no memo';
  // This violates the rules of React, so we access the ref in a child
  // component
  return ref.current;
}

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

Subdomains

Functions

Dependencies

  • react

Frequently Asked Questions

What does allow-ref-access-in-unused-callback-nested.js do?
allow-ref-access-in-unused-callback-nested.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-ref-access-in-unused-callback-nested.js?
allow-ref-access-in-unused-callback-nested.js defines 2 function(s): Child, Component.
What does allow-ref-access-in-unused-callback-nested.js depend on?
allow-ref-access-in-unused-callback-nested.js imports 1 module(s): react.
Where is allow-ref-access-in-unused-callback-nested.js in the architecture?
allow-ref-access-in-unused-callback-nested.js is located at compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/allow-ref-access-in-unused-callback-nested.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