Home / File/ UIManager.js — react Source File

UIManager.js — react Source File

Architecture documentation for UIManager.js, a javascript file in the react codebase.

Entity Profile

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.
 */

'use strict';

// Mock of the Native Hooks

// Map of viewTag -> {children: [childTag], parent: ?parentTag}
const roots = [];
const views = new Map();

function autoCreateRoot(tag) {
  // Seriously, this is how we distinguish roots in RN.
  if (!views.has(tag) && tag % 10 === 1) {
    roots.push(tag);
    views.set(tag, {
      children: [],
      parent: null,
      props: {},
      viewName: '<native root>',
    });
  }
}

function insertSubviewAtIndex(parent, child, index) {
  const parentInfo = views.get(parent);
  const childInfo = views.get(child);

  if (childInfo.parent !== null) {
    throw new Error(
      `Inserting view ${child} ${JSON.stringify(
        childInfo.props,
      )} which already has parent`,
    );
  }

  if (0 > index || index > parentInfo.children.length) {
    throw new Error(
      `Invalid index ${index} for children ${parentInfo.children}`,
    );
  }

  parentInfo.children.splice(index, 0, child);
  childInfo.parent = parent;
}

function removeChild(parent, child) {
  const parentInfo = views.get(parent);
  const childInfo = views.get(child);
  const index = parentInfo.children.indexOf(child);

  if (index < 0) {
    throw new Error(`Missing view ${child} during removal`);
  }

  parentInfo.children.splice(index, 1);
// ... (135 more lines)

Domain

Subdomains

Frequently Asked Questions

What does UIManager.js do?
UIManager.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 UIManager.js?
UIManager.js defines 4 function(s): RCTUIManager.__dumpHierarchyForJestTestsOnly, autoCreateRoot, insertSubviewAtIndex, removeChild.
Where is UIManager.js in the architecture?
UIManager.js is located at packages/react-native-renderer/src/__mocks__/react-native/Libraries/ReactPrivate/UIManager.js (domain: BabelCompiler, subdomain: Validation, directory: packages/react-native-renderer/src/__mocks__/react-native/Libraries/ReactPrivate).

Analyze Your Own Codebase

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

Try Supermodel Free