Home / File/ SnapshotSelector.js — react Source File

SnapshotSelector.js — react Source File

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

File javascript BabelCompiler Validation 11 imports 1 dependents 1 functions

Entity Profile

Dependency Diagram

graph LR
  b350cf53_cbc3_d273_ad6c_5485a91ef713["SnapshotSelector.js"]
  f9049b08_60f8_abce_a6a6_153f88447124["Button.js"]
  b350cf53_cbc3_d273_ad6c_5485a91ef713 --> f9049b08_60f8_abce_a6a6_153f88447124
  f71ee326_17f0_7db4_4178_2763fb1c2ad1["Button"]
  b350cf53_cbc3_d273_ad6c_5485a91ef713 --> f71ee326_17f0_7db4_4178_2763fb1c2ad1
  9f39024f_b905_9b0f_2fc7_e24785732638["ButtonIcon.js"]
  b350cf53_cbc3_d273_ad6c_5485a91ef713 --> 9f39024f_b905_9b0f_2fc7_e24785732638
  4690d9c0_cb81_9593_7817_f9e61a49f9e7["ButtonIcon"]
  b350cf53_cbc3_d273_ad6c_5485a91ef713 --> 4690d9c0_cb81_9593_7817_f9e61a49f9e7
  6c4f87a5_052e_5ad2_3388_1e4392b92a53["ProfilerContext.js"]
  b350cf53_cbc3_d273_ad6c_5485a91ef713 --> 6c4f87a5_052e_5ad2_3388_1e4392b92a53
  76384bd4_08c7_de17_1f91_2937028def49["SnapshotCommitList.js"]
  b350cf53_cbc3_d273_ad6c_5485a91ef713 --> 76384bd4_08c7_de17_1f91_2937028def49
  be84ff73_f936_f0a0_527b_3468b101ca1f["SnapshotCommitList"]
  b350cf53_cbc3_d273_ad6c_5485a91ef713 --> be84ff73_f936_f0a0_527b_3468b101ca1f
  f14bbaea_a3f1_245b_696c_0c4d0bd624c7["constants.js"]
  b350cf53_cbc3_d273_ad6c_5485a91ef713 --> f14bbaea_a3f1_245b_696c_0c4d0bd624c7
  913bb343_55ea_f1b8_08f5_b75cb0a92b76["context.js"]
  b350cf53_cbc3_d273_ad6c_5485a91ef713 --> 913bb343_55ea_f1b8_08f5_b75cb0a92b76
  712918e1_29cf_5883_03af_b1eebd29027e["SnapshotSelector.css"]
  b350cf53_cbc3_d273_ad6c_5485a91ef713 --> 712918e1_29cf_5883_03af_b1eebd29027e
  ac587885_e294_a1e9_b13f_5e7b920fdb42["react"]
  b350cf53_cbc3_d273_ad6c_5485a91ef713 --> ac587885_e294_a1e9_b13f_5e7b920fdb42
  2e59ff66_9c56_6e37_8843_8e474e6b0d70["Profiler.js"]
  2e59ff66_9c56_6e37_8843_8e474e6b0d70 --> b350cf53_cbc3_d273_ad6c_5485a91ef713
  style b350cf53_cbc3_d273_ad6c_5485a91ef713 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 Button from '../Button';
import ButtonIcon from '../ButtonIcon';
import {ProfilerContext} from './ProfilerContext';
import SnapshotCommitList from './SnapshotCommitList';
import {maxBarWidth} from './constants';
import {StoreContext} from '../context';

import styles from './SnapshotSelector.css';

export type Props = {};

export default function SnapshotSelector(_: Props): React.Node {
  const {
    rootID,
    selectedCommitIndex,
    selectCommitIndex,
    selectPrevCommitIndex,
    selectNextCommitIndex,
    filteredCommitIndices,
    selectedFilteredCommitIndex,
  } = useContext(ProfilerContext);

  const {profilerStore} = useContext(StoreContext);
  const {commitData} = profilerStore.getDataForRoot(((rootID: any): number));

  const totalDurations: Array<number> = [];
  const commitTimes: Array<number> = [];
  commitData.forEach(commitDatum => {
    totalDurations.push(
      commitDatum.duration +
        (commitDatum.effectDuration || 0) +
        (commitDatum.passiveEffectDuration || 0),
    );
    commitTimes.push(commitDatum.timestamp);
  });

  const numFilteredCommits = filteredCommitIndices.length;

  let label = null;
  if (numFilteredCommits > 0) {
    // $FlowFixMe[missing-local-annot]
    const handleCommitInputChange = event => {
      const value = parseInt(event.currentTarget.value, 10);
      if (!isNaN(value)) {
        const filteredIndex = Math.min(
          Math.max(value - 1, 0),

          // Snashots are shown to the user as 1-based
          // but the indices within the profiler data array ar 0-based.
// ... (125 more lines)

Domain

Subdomains

Functions

Frequently Asked Questions

What does SnapshotSelector.js do?
SnapshotSelector.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 SnapshotSelector.js?
SnapshotSelector.js defines 1 function(s): SnapshotSelector.
What does SnapshotSelector.js depend on?
SnapshotSelector.js imports 11 module(s): Button, Button.js, ButtonIcon, ButtonIcon.js, ProfilerContext.js, SnapshotCommitList, SnapshotCommitList.js, SnapshotSelector.css, and 3 more.
What files import SnapshotSelector.js?
SnapshotSelector.js is imported by 1 file(s): Profiler.js.
Where is SnapshotSelector.js in the architecture?
SnapshotSelector.js is located at packages/react-devtools-shared/src/devtools/views/Profiler/SnapshotSelector.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