Home / File/ validateDOMNesting.js — react Source File

validateDOMNesting.js — react Source File

Architecture documentation for validateDOMNesting.js, a javascript file in the react codebase. 4 imports, 2 dependents.

File javascript BabelCompiler Validation 4 imports 2 dependents 7 functions

Entity Profile

Dependency Diagram

graph LR
  99b6f05f_c8d3_afa4_842b_34ebebb1f8a7["validateDOMNesting.js"]
  42892443_e223_3da0_aeb9_e1b32a408fb0["ReactInternalTypes"]
  99b6f05f_c8d3_afa4_842b_34ebebb1f8a7 --> 42892443_e223_3da0_aeb9_e1b32a408fb0
  48b09619_eddb_a204_6cda_cb487cb5ed53["ReactFiberHydrationDiffs"]
  99b6f05f_c8d3_afa4_842b_34ebebb1f8a7 --> 48b09619_eddb_a204_6cda_cb487cb5ed53
  9a7dedff_ebb2_a1a9_a4c3_be4ea69f001e["ReactCurrentFiber"]
  99b6f05f_c8d3_afa4_842b_34ebebb1f8a7 --> 9a7dedff_ebb2_a1a9_a4c3_be4ea69f001e
  f8f61929_42ba_4030_bc4f_a1c5484f5f32["ReactWorkTags"]
  99b6f05f_c8d3_afa4_842b_34ebebb1f8a7 --> f8f61929_42ba_4030_bc4f_a1c5484f5f32
  1e990658_7cea_75be_1f24_2399bdf9f15b["ReactDOMComponent.js"]
  1e990658_7cea_75be_1f24_2399bdf9f15b --> 99b6f05f_c8d3_afa4_842b_34ebebb1f8a7
  9c694103_7f39_88d0_6b4d_f9b2ffed5731["ReactFiberConfigDOM.js"]
  9c694103_7f39_88d0_6b4d_f9b2ffed5731 --> 99b6f05f_c8d3_afa4_842b_34ebebb1f8a7
  style 99b6f05f_c8d3_afa4_842b_34ebebb1f8a7 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

/**
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 *
 * @flow
 */

import type {Fiber} from 'react-reconciler/src/ReactInternalTypes';
import type {HydrationDiffNode} from 'react-reconciler/src/ReactFiberHydrationDiffs';

import {
  current,
  runWithFiberInDEV,
} from 'react-reconciler/src/ReactCurrentFiber';
import {
  HostComponent,
  HostHoistable,
  HostSingleton,
  HostText,
} from 'react-reconciler/src/ReactWorkTags';

import {describeDiff} from 'react-reconciler/src/ReactFiberHydrationDiffs';

function describeAncestors(
  ancestor: Fiber,
  child: Fiber,
  props: null | {children: null},
): string {
  let fiber: null | Fiber = child;
  let node: null | HydrationDiffNode = null;
  let distanceFromLeaf = 0;
  while (fiber) {
    if (fiber === ancestor) {
      distanceFromLeaf = 0;
    }
    node = {
      fiber: fiber,
      children: node !== null ? [node] : [],
      serverProps:
        fiber === child ? props : fiber === ancestor ? null : undefined,
      serverTail: [],
      distanceFromLeaf: distanceFromLeaf,
    };
    distanceFromLeaf++;
    fiber = fiber.return;
  }
  if (node !== null) {
    // Describe the node using the hydration diff logic.
    // Replace + with - to mark ancestor and child. It's kind of arbitrary.
    return describeDiff(node).replaceAll(/^[+-]/gm, '>');
  }
  return '';
}

type Info = {tag: string};
export type AncestorInfoDev = {
  current: ?Info,

// ... (634 more lines)

Domain

Subdomains

Dependencies

  • ReactCurrentFiber
  • ReactFiberHydrationDiffs
  • ReactInternalTypes
  • ReactWorkTags

Frequently Asked Questions

What does validateDOMNesting.js do?
validateDOMNesting.js is a source file in the react codebase, written in javascript. It belongs to the BabelCompiler domain, Validation subdomain.
What functions are defined in validateDOMNesting.js?
validateDOMNesting.js defines 7 function(s): describeAncestors, findAncestor, findInvalidAncestorForTag, isTagValidWithParent, updatedAncestorInfoDev, validateDOMNesting, validateTextNesting.
What does validateDOMNesting.js depend on?
validateDOMNesting.js imports 4 module(s): ReactCurrentFiber, ReactFiberHydrationDiffs, ReactInternalTypes, ReactWorkTags.
What files import validateDOMNesting.js?
validateDOMNesting.js is imported by 2 file(s): ReactDOMComponent.js, ReactFiberConfigDOM.js.
Where is validateDOMNesting.js in the architecture?
validateDOMNesting.js is located at packages/react-dom-bindings/src/client/validateDOMNesting.js (domain: BabelCompiler, subdomain: Validation, directory: packages/react-dom-bindings/src/client).

Analyze Your Own Codebase

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

Try Supermodel Free