Home / File/ InspectedElementErrorBoundary.js — react Source File

InspectedElementErrorBoundary.js — react Source File

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

File javascript BabelCompiler Validation 5 imports 2 dependents 1 functions

Entity Profile

Dependency Diagram

graph LR
  8d1aac2b_7bad_9e53_cab3_6414b0d9e4c5["InspectedElementErrorBoundary.js"]
  bc8655f0_277c_51b9_bdf3_da523644e54b["index.js"]
  8d1aac2b_7bad_9e53_cab3_6414b0d9e4c5 --> bc8655f0_277c_51b9_bdf3_da523644e54b
  2d59b0f9_9ad6_da4d_0264_d98f193ab3fd["TreeContext.js"]
  8d1aac2b_7bad_9e53_cab3_6414b0d9e4c5 --> 2d59b0f9_9ad6_da4d_0264_d98f193ab3fd
  6bac32d3_6539_c154_fc1b_37182f68d9ed["inspectedElementCache.js"]
  8d1aac2b_7bad_9e53_cab3_6414b0d9e4c5 --> 6bac32d3_6539_c154_fc1b_37182f68d9ed
  0c82829e_7b3b_eaaf_7db1_ef352060d02a["InspectedElementErrorBoundary.css"]
  8d1aac2b_7bad_9e53_cab3_6414b0d9e4c5 --> 0c82829e_7b3b_eaaf_7db1_ef352060d02a
  ac587885_e294_a1e9_b13f_5e7b920fdb42["react"]
  8d1aac2b_7bad_9e53_cab3_6414b0d9e4c5 --> ac587885_e294_a1e9_b13f_5e7b920fdb42
  a2fac529_5caa_fd15_61d0_e5b11d75bdd2["Components.js"]
  a2fac529_5caa_fd15_61d0_e5b11d75bdd2 --> 8d1aac2b_7bad_9e53_cab3_6414b0d9e4c5
  3249b7c1_ae10_2672_10ce_a66fd0ee6f60["SuspenseTab.js"]
  3249b7c1_ae10_2672_10ce_a66fd0ee6f60 --> 8d1aac2b_7bad_9e53_cab3_6414b0d9e4c5
  style 8d1aac2b_7bad_9e53_cab3_6414b0d9e4c5 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 * as React from 'react';
import {
  useCallback,
  useContext,
  unstable_useCacheRefresh as useCacheRefresh,
} from 'react';
import ErrorBoundary from '../ErrorBoundary';
import {TreeStateContext} from './TreeContext';
import {clearCacheBecauseOfError} from '../../../inspectedElementCache';
import styles from './InspectedElementErrorBoundary.css';

type WrapperProps = {
  children: React$Node,
};

export default function InspectedElementErrorBoundaryWrapper({
  children,
}: WrapperProps): React.Node {
  // Key on the selected element ID so that changing the selected element automatically hides the boundary.
  // This seems best since an error inspecting one element isn't likely to be relevant to another element.
  const {inspectedElementID} = useContext(TreeStateContext);

  const refresh = useCacheRefresh();
  const handleDsmiss = useCallback(() => {
    clearCacheBecauseOfError(refresh);
  }, [refresh]);

  return (
    <div className={styles.Wrapper}>
      <ErrorBoundary
        key={inspectedElementID}
        canDismiss={true}
        onBeforeDismissCallback={handleDsmiss}>
        {children}
      </ErrorBoundary>
    </div>
  );
}

Domain

Subdomains

Frequently Asked Questions

What does InspectedElementErrorBoundary.js do?
InspectedElementErrorBoundary.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 InspectedElementErrorBoundary.js?
InspectedElementErrorBoundary.js defines 1 function(s): InspectedElementErrorBoundaryWrapper.
What does InspectedElementErrorBoundary.js depend on?
InspectedElementErrorBoundary.js imports 5 module(s): InspectedElementErrorBoundary.css, TreeContext.js, index.js, inspectedElementCache.js, react.
What files import InspectedElementErrorBoundary.js?
InspectedElementErrorBoundary.js is imported by 2 file(s): Components.js, SuspenseTab.js.
Where is InspectedElementErrorBoundary.js in the architecture?
InspectedElementErrorBoundary.js is located at packages/react-devtools-shared/src/devtools/views/Components/InspectedElementErrorBoundary.js (domain: BabelCompiler, subdomain: Validation, directory: packages/react-devtools-shared/src/devtools/views/Components).

Analyze Your Own Codebase

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

Try Supermodel Free