Home / File/ RootSelector.js — react Source File

RootSelector.js — react Source File

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

File javascript BabelCompiler Validation 3 imports 1 dependents 1 functions

Entity Profile

Dependency Diagram

graph LR
  56e5ec4a_e49d_d34a_3ddb_87540ffc05ef["RootSelector.js"]
  6c4f87a5_052e_5ad2_3388_1e4392b92a53["ProfilerContext.js"]
  56e5ec4a_e49d_d34a_3ddb_87540ffc05ef --> 6c4f87a5_052e_5ad2_3388_1e4392b92a53
  38e29516_d383_4f36_74e6_02535a81af11["RootSelector.css"]
  56e5ec4a_e49d_d34a_3ddb_87540ffc05ef --> 38e29516_d383_4f36_74e6_02535a81af11
  ac587885_e294_a1e9_b13f_5e7b920fdb42["react"]
  56e5ec4a_e49d_d34a_3ddb_87540ffc05ef --> ac587885_e294_a1e9_b13f_5e7b920fdb42
  2e59ff66_9c56_6e37_8843_8e474e6b0d70["Profiler.js"]
  2e59ff66_9c56_6e37_8843_8e474e6b0d70 --> 56e5ec4a_e49d_d34a_3ddb_87540ffc05ef
  style 56e5ec4a_e49d_d34a_3ddb_87540ffc05ef 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, useCallback, useContext} from 'react';
import {ProfilerContext} from './ProfilerContext';

import styles from './RootSelector.css';

export default function RootSelector(_: {}): React.Node {
  const {profilingData, rootID, setRootID} = useContext(ProfilerContext);

  const options = [];
  if (profilingData !== null) {
    profilingData.dataForRoots.forEach((dataForRoot, id) => {
      options.push(
        <option key={id} value={id}>
          {dataForRoot.displayName}
        </option>,
      );
    });
  }

  const handleChange = useCallback(
    ({currentTarget}: $FlowFixMe) => {
      setRootID(parseInt(currentTarget.value, 10));
    },
    [setRootID],
  );

  if (profilingData === null || profilingData.dataForRoots.size <= 1) {
    // Don't take up visual space if there's only one root.
    return null;
  }

  return (
    <Fragment>
      <div className={styles.Spacer} />
      <select value={rootID} onChange={handleChange}>
        {options}
      </select>
    </Fragment>
  );
}

Domain

Subdomains

Functions

Frequently Asked Questions

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