Home / File/ attachRenderer.js — react Source File

attachRenderer.js — react Source File

Architecture documentation for attachRenderer.js, a javascript file in the react codebase. 6 imports, 1 dependents.

File javascript BabelCompiler Validation 6 imports 1 dependents 1 functions

Entity Profile

Dependency Diagram

graph LR
  7d512385_b713_0511_a399_af3e878800fe["attachRenderer.js"]
  40bf6909_04ae_bfb6_965f_14cfe98b94de["types"]
  7d512385_b713_0511_a399_af3e878800fe --> 40bf6909_04ae_bfb6_965f_14cfe98b94de
  aec7978f_0a19_ba93_de9e_ac8cf5ddc74b["types"]
  7d512385_b713_0511_a399_af3e878800fe --> aec7978f_0a19_ba93_de9e_ac8cf5ddc74b
  48885187_23bb_c099_4110_2e321afefd49["renderer"]
  7d512385_b713_0511_a399_af3e878800fe --> 48885187_23bb_c099_4110_2e321afefd49
  65865af4_59ca_2307_39d0_3101b36f5375["renderer"]
  7d512385_b713_0511_a399_af3e878800fe --> 65865af4_59ca_2307_39d0_3101b36f5375
  472b58ab_5d2d_62b5_7af9_8218bfd4e514["renderer"]
  7d512385_b713_0511_a399_af3e878800fe --> 472b58ab_5d2d_62b5_7af9_8218bfd4e514
  80162ac2_4fc9_259b_04e9_4acc940af136["utils"]
  7d512385_b713_0511_a399_af3e878800fe --> 80162ac2_4fc9_259b_04e9_4acc940af136
  a49c4f66_71d5_8a62_f0a1_ffd7ca7bd5b2["hook.js"]
  a49c4f66_71d5_8a62_f0a1_ffd7ca7bd5b2 --> 7d512385_b713_0511_a399_af3e878800fe
  style 7d512385_b713_0511_a399_af3e878800fe 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 {
  ReactRenderer,
  RendererInterface,
  DevToolsHook,
  RendererID,
  ProfilingSettings,
} from 'react-devtools-shared/src/backend/types';
import type {ComponentFilter} from 'react-devtools-shared/src/frontend/types';

import {attach as attachFlight} from 'react-devtools-shared/src/backend/flight/renderer';
import {attach as attachFiber} from 'react-devtools-shared/src/backend/fiber/renderer';
import {attach as attachLegacy} from 'react-devtools-shared/src/backend/legacy/renderer';
import {hasAssignedBackend} from 'react-devtools-shared/src/backend/utils';

// this is the backend that is compatible with all older React versions
function isMatchingRender(version: string): boolean {
  return !hasAssignedBackend(version);
}

export default function attachRenderer(
  hook: DevToolsHook,
  id: RendererID,
  renderer: ReactRenderer,
  global: Object,
  shouldStartProfilingNow: boolean,
  profilingSettings: ProfilingSettings,
  componentFiltersOrComponentFiltersPromise:
    | Array<ComponentFilter>
    | Promise<Array<ComponentFilter>>,
): RendererInterface | void {
  // only attach if the renderer is compatible with the current version of the backend
  if (!isMatchingRender(renderer.reconcilerVersion || renderer.version)) {
    return;
  }
  let rendererInterface = hook.rendererInterfaces.get(id);

  // Inject any not-yet-injected renderers (if we didn't reload-and-profile)
  if (rendererInterface == null) {
    if (typeof renderer.getCurrentComponentInfo === 'function') {
      // react-flight/client
      rendererInterface = attachFlight(hook, id, renderer, global);
    } else if (
      // v16-19
      typeof renderer.findFiberByHostInstance === 'function' ||
      // v16.8+
      renderer.currentDispatcherRef != null
    ) {
      // react-reconciler v16+
      rendererInterface = attachFiber(
        hook,
        id,
        renderer,
        global,
        shouldStartProfilingNow,
        profilingSettings,
        componentFiltersOrComponentFiltersPromise,
      );
    } else if (renderer.ComponentTree) {
      // react-dom v15
      rendererInterface = attachLegacy(hook, id, renderer, global);
    } else {
      // Older react-dom or other unsupported renderer version
    }
  }

  return rendererInterface;
}

Domain

Subdomains

Functions

Dependencies

  • renderer
  • renderer
  • renderer
  • types
  • types
  • utils

Frequently Asked Questions

What does attachRenderer.js do?
attachRenderer.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 attachRenderer.js?
attachRenderer.js defines 1 function(s): isMatchingRender.
What does attachRenderer.js depend on?
attachRenderer.js imports 6 module(s): renderer, renderer, renderer, types, types, utils.
What files import attachRenderer.js?
attachRenderer.js is imported by 1 file(s): hook.js.
Where is attachRenderer.js in the architecture?
attachRenderer.js is located at packages/react-devtools-shared/src/attachRenderer.js (domain: BabelCompiler, subdomain: Validation, directory: packages/react-devtools-shared/src).

Analyze Your Own Codebase

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

Try Supermodel Free