Home / File/ ReactFabricComponentTree.js — react Source File

ReactFabricComponentTree.js — react Source File

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

File javascript BabelCompiler 2 imports 2 dependents

Entity Profile

Dependency Diagram

graph LR
  61e5e184_347f_baa9_51f4_1ca787b4b252["ReactFabricComponentTree.js"]
  948a0d34_693c_c158_f23e_d41306507c72["ReactFiberConfigFabric.js"]
  61e5e184_347f_baa9_51f4_1ca787b4b252 --> 948a0d34_693c_c158_f23e_d41306507c72
  42892443_e223_3da0_aeb9_e1b32a408fb0["ReactInternalTypes"]
  61e5e184_347f_baa9_51f4_1ca787b4b252 --> 42892443_e223_3da0_aeb9_e1b32a408fb0
  f5f93cbf_f7fc_49fc_c1ef_17ea4ef34d0e["ReactFabricInjection.js"]
  f5f93cbf_f7fc_49fc_c1ef_17ea4ef34d0e --> 61e5e184_347f_baa9_51f4_1ca787b4b252
  948a0d34_693c_c158_f23e_d41306507c72["ReactFiberConfigFabric.js"]
  948a0d34_693c_c158_f23e_d41306507c72 --> 61e5e184_347f_baa9_51f4_1ca787b4b252
  style 61e5e184_347f_baa9_51f4_1ca787b4b252 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 strict-local
 */

import type {
  PublicInstance,
  Instance,
  Props,
  TextInstance,
} from './ReactFiberConfigFabric';
import type {Fiber} from 'react-reconciler/src/ReactInternalTypes';
import {getPublicInstance} from './ReactFiberConfigFabric';

// `node` is typed incorrectly here. The proper type should be `PublicInstance`.
// This is ok in DOM because they types are interchangeable, but in React Native
// they aren't.
function getInstanceFromNode(node: Instance | TextInstance): Fiber | null {
  const instance: Instance = (node: $FlowFixMe); // In React Native, node is never a text instance

  if (
    instance.canonical != null &&
    instance.canonical.internalInstanceHandle != null
  ) {
    return instance.canonical.internalInstanceHandle;
  }

  // $FlowFixMe[incompatible-return] DevTools incorrectly passes a fiber in React Native.
  return node;
}

function getNodeFromInstance(fiber: Fiber): PublicInstance {
  const publicInstance = getPublicInstance(fiber.stateNode);

  if (publicInstance == null) {
    throw new Error('Could not find host instance from fiber');
  }

  return publicInstance;
}

function getFiberCurrentPropsFromNode(instance: Instance): Props {
  return instance.canonical.currentProps;
}

export {
  getInstanceFromNode,
  getInstanceFromNode as getClosestInstanceFromNode,
  getNodeFromInstance,
  getFiberCurrentPropsFromNode,
};

Domain

Dependencies

Frequently Asked Questions

What does ReactFabricComponentTree.js do?
ReactFabricComponentTree.js is a source file in the react codebase, written in javascript. It belongs to the BabelCompiler domain.
What does ReactFabricComponentTree.js depend on?
ReactFabricComponentTree.js imports 2 module(s): ReactFiberConfigFabric.js, ReactInternalTypes.
What files import ReactFabricComponentTree.js?
ReactFabricComponentTree.js is imported by 2 file(s): ReactFabricInjection.js, ReactFiberConfigFabric.js.
Where is ReactFabricComponentTree.js in the architecture?
ReactFabricComponentTree.js is located at packages/react-native-renderer/src/ReactFabricComponentTree.js (domain: BabelCompiler, directory: packages/react-native-renderer/src).

Analyze Your Own Codebase

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

Try Supermodel Free