Home / File/ nonreactive-ref-helper.js — react Source File

nonreactive-ref-helper.js — react Source File

Architecture documentation for nonreactive-ref-helper.js, a javascript file in the react codebase. 2 imports, 0 dependents.

File javascript TestingUtilities Fixtures 2 imports 3 functions

Entity Profile

Dependency Diagram

graph LR
  e753ac9c_1e57_0170_66ea_3e490ed59086["nonreactive-ref-helper.js"]
  ac587885_e294_a1e9_b13f_5e7b920fdb42["react"]
  e753ac9c_1e57_0170_66ea_3e490ed59086 --> ac587885_e294_a1e9_b13f_5e7b920fdb42
  006eec3d_77a9_4a47_e6c1_a96d7a6c9c05["shared-runtime"]
  e753ac9c_1e57_0170_66ea_3e490ed59086 --> 006eec3d_77a9_4a47_e6c1_a96d7a6c9c05
  style e753ac9c_1e57_0170_66ea_3e490ed59086 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

// @inferEffectDependencies
import {useEffect, AUTODEPS} from 'react';
import {print} from 'shared-runtime';

/**
 * We never include a .current access in a dep array because it may be a ref access.
 * This might over-capture objects that are not refs and happen to have fields named
 * current, but that should be a rare case and the result would still be correct
 * (assuming the effect is idempotent). In the worst case, you can always write a manual
 * dep array.
 */
function RefsInEffects() {
  const ref = useRefHelper();
  const wrapped = useDeeperRefHelper();
  useEffect(() => {
    print(ref.current);
    print(wrapped.foo.current);
  }, AUTODEPS);
}

function useRefHelper() {
  return useRef(0);
}

function useDeeperRefHelper() {
  return {foo: useRefHelper()};
}

Subdomains

Dependencies

  • react
  • shared-runtime

Frequently Asked Questions

What does nonreactive-ref-helper.js do?
nonreactive-ref-helper.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 nonreactive-ref-helper.js?
nonreactive-ref-helper.js defines 3 function(s): RefsInEffects, useDeeperRefHelper, useRefHelper.
What does nonreactive-ref-helper.js depend on?
nonreactive-ref-helper.js imports 2 module(s): react, shared-runtime.
Where is nonreactive-ref-helper.js in the architecture?
nonreactive-ref-helper.js is located at compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/infer-effect-dependencies/nonreactive-ref-helper.js (domain: TestingUtilities, subdomain: Fixtures, directory: compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/infer-effect-dependencies).

Analyze Your Own Codebase

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

Try Supermodel Free