Home / File/ HoveredFiberInfo.js — react Source File

HoveredFiberInfo.js — react Source File

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

File javascript BabelCompiler Validation 10 imports 2 dependents 1 functions

Entity Profile

Dependency Diagram

graph LR
  38d38257_86b3_3154_4c21_7fbaf41be1cb["HoveredFiberInfo.js"]
  d5989364_e16c_e349_6082_7c3e50da7772["InspectedElementBadges.js"]
  38d38257_86b3_3154_4c21_7fbaf41be1cb --> d5989364_e16c_e349_6082_7c3e50da7772
  96fe9a6e_9e70_bef0_7ce0_b2431ac09b94["InspectedElementBadges"]
  38d38257_86b3_3154_4c21_7fbaf41be1cb --> 96fe9a6e_9e70_bef0_7ce0_b2431ac09b94
  6c4f87a5_052e_5ad2_3388_1e4392b92a53["ProfilerContext.js"]
  38d38257_86b3_3154_4c21_7fbaf41be1cb --> 6c4f87a5_052e_5ad2_3388_1e4392b92a53
  0f941e70_3fdb_aa42_7939_2878d5d4125b["utils.js"]
  38d38257_86b3_3154_4c21_7fbaf41be1cb --> 0f941e70_3fdb_aa42_7939_2878d5d4125b
  5e16f57b_1380_519b_fff9_378869430fab["WhatChanged.js"]
  38d38257_86b3_3154_4c21_7fbaf41be1cb --> 5e16f57b_1380_519b_fff9_378869430fab
  a8ba359b_010b_f4bf_4c0f_5d6da6d37ad9["WhatChanged"]
  38d38257_86b3_3154_4c21_7fbaf41be1cb --> a8ba359b_010b_f4bf_4c0f_5d6da6d37ad9
  913bb343_55ea_f1b8_08f5_b75cb0a92b76["context.js"]
  38d38257_86b3_3154_4c21_7fbaf41be1cb --> 913bb343_55ea_f1b8_08f5_b75cb0a92b76
  82e4c80f_d61d_917c_165f_898e80c6004d["HoveredFiberInfo.css"]
  38d38257_86b3_3154_4c21_7fbaf41be1cb --> 82e4c80f_d61d_917c_165f_898e80c6004d
  9d7f3d0b_1959_a3f3_e24e_821787aa2f54["FlamegraphChartBuilder.js"]
  38d38257_86b3_3154_4c21_7fbaf41be1cb --> 9d7f3d0b_1959_a3f3_e24e_821787aa2f54
  ac587885_e294_a1e9_b13f_5e7b920fdb42["react"]
  38d38257_86b3_3154_4c21_7fbaf41be1cb --> ac587885_e294_a1e9_b13f_5e7b920fdb42
  54e7a598_e83a_4b14_3104_1fa62a034c31["CommitFlamegraph.js"]
  54e7a598_e83a_4b14_3104_1fa62a034c31 --> 38d38257_86b3_3154_4c21_7fbaf41be1cb
  0ad6c6d5_5d6d_2d8a_d957_e1433af66ea0["CommitRanked.js"]
  0ad6c6d5_5d6d_2d8a_d957_e1433af66ea0 --> 38d38257_86b3_3154_4c21_7fbaf41be1cb
  style 38d38257_86b3_3154_4c21_7fbaf41be1cb 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 {Fragment, useContext} from 'react';

import InspectedElementBadges from '../Components/InspectedElementBadges';
import {ProfilerContext} from './ProfilerContext';
import {formatDuration} from './utils';
import WhatChanged from './WhatChanged';
import {StoreContext} from '../context';

import styles from './HoveredFiberInfo.css';

import type {ChartNode} from './FlamegraphChartBuilder';

export type TooltipFiberData = {
  id: number,
  name: string,
};

export type Props = {
  fiberData: ChartNode,
};

export default function HoveredFiberInfo({fiberData}: Props): React.Node {
  const {profilerStore} = useContext(StoreContext);
  const {rootID, selectedCommitIndex} = useContext(ProfilerContext);

  const {id, name} = fiberData;
  const {profilingCache} = profilerStore;

  if (rootID === null || selectedCommitIndex === null) {
    return null;
  }

  const commitIndices = profilingCache.getFiberCommits({
    fiberID: id,
    rootID,
  });

  const {nodes} = profilingCache.getCommitTree({
    rootID,
    commitIndex: selectedCommitIndex,
  });
  const node = nodes.get(id);

  let renderDurationInfo = null;
  let i = 0;
  for (i = 0; i < commitIndices.length; i++) {
    const commitIndex = commitIndices[i];
    if (selectedCommitIndex === commitIndex) {
      const {fiberActualDurations, fiberSelfDurations} =
        profilerStore.getCommitData(((rootID: any): number), commitIndex);
      const actualDuration = fiberActualDurations.get(id) || 0;
      const selfDuration = fiberSelfDurations.get(id) || 0;

      renderDurationInfo = (
        <div key={commitIndex} className={styles.CurrentCommit}>
          <strong>Duration:</strong> {formatDuration(selfDuration)}ms of{' '}
          {formatDuration(actualDuration)}ms
        </div>
      );

      break;
    }
  }

  return (
    <Fragment>
      <div className={styles.Toolbar}>
        <div className={styles.Component}>{name}</div>

        {node != null && (
          <div className={styles.BadgesContainer}>
            <InspectedElementBadges
              hocDisplayNames={node.hocDisplayNames}
              compiledWithForget={node.compiledWithForget}
            />

            {node.compiledWithForget && (
              <div>
                ✨ This component has been auto-memoized by the React Compiler.
              </div>
            )}
          </div>
        )}

        <div className={styles.Content}>
          {renderDurationInfo || <div>Did not client render.</div>}

          <WhatChanged fiberID={id} displayMode="compact" />
        </div>
      </div>
    </Fragment>
  );
}

Domain

Subdomains

Functions

Frequently Asked Questions

What does HoveredFiberInfo.js do?
HoveredFiberInfo.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 HoveredFiberInfo.js?
HoveredFiberInfo.js defines 1 function(s): HoveredFiberInfo.
What does HoveredFiberInfo.js depend on?
HoveredFiberInfo.js imports 10 module(s): FlamegraphChartBuilder.js, HoveredFiberInfo.css, InspectedElementBadges, InspectedElementBadges.js, ProfilerContext.js, WhatChanged, WhatChanged.js, context.js, and 2 more.
What files import HoveredFiberInfo.js?
HoveredFiberInfo.js is imported by 2 file(s): CommitFlamegraph.js, CommitRanked.js.
Where is HoveredFiberInfo.js in the architecture?
HoveredFiberInfo.js is located at packages/react-devtools-shared/src/devtools/views/Profiler/HoveredFiberInfo.js (domain: BabelCompiler, subdomain: Validation, directory: packages/react-devtools-shared/src/devtools/views/Profiler).

Analyze Your Own Codebase

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

Try Supermodel Free