Home / File/ ReloadAndProfileButton.js — react Source File

ReloadAndProfileButton.js — react Source File

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

File javascript BabelCompiler Validation 7 imports 1 dependents 1 functions

Entity Profile

Dependency Diagram

graph LR
  cfab091f_c28b_64cf_b7bc_c73383eec59f["ReloadAndProfileButton.js"]
  f9049b08_60f8_abce_a6a6_153f88447124["Button.js"]
  cfab091f_c28b_64cf_b7bc_c73383eec59f --> f9049b08_60f8_abce_a6a6_153f88447124
  f71ee326_17f0_7db4_4178_2763fb1c2ad1["Button"]
  cfab091f_c28b_64cf_b7bc_c73383eec59f --> f71ee326_17f0_7db4_4178_2763fb1c2ad1
  9f39024f_b905_9b0f_2fc7_e24785732638["ButtonIcon.js"]
  cfab091f_c28b_64cf_b7bc_c73383eec59f --> 9f39024f_b905_9b0f_2fc7_e24785732638
  4690d9c0_cb81_9593_7817_f9e61a49f9e7["ButtonIcon"]
  cfab091f_c28b_64cf_b7bc_c73383eec59f --> 4690d9c0_cb81_9593_7817_f9e61a49f9e7
  913bb343_55ea_f1b8_08f5_b75cb0a92b76["context.js"]
  cfab091f_c28b_64cf_b7bc_c73383eec59f --> 913bb343_55ea_f1b8_08f5_b75cb0a92b76
  315baf50_1028_51ca_a9c1_679c6a17ed98["hooks.js"]
  cfab091f_c28b_64cf_b7bc_c73383eec59f --> 315baf50_1028_51ca_a9c1_679c6a17ed98
  ac587885_e294_a1e9_b13f_5e7b920fdb42["react"]
  cfab091f_c28b_64cf_b7bc_c73383eec59f --> ac587885_e294_a1e9_b13f_5e7b920fdb42
  2e59ff66_9c56_6e37_8843_8e474e6b0d70["Profiler.js"]
  2e59ff66_9c56_6e37_8843_8e474e6b0d70 --> cfab091f_c28b_64cf_b7bc_c73383eec59f
  style cfab091f_c28b_64cf_b7bc_c73383eec59f 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, useMemo} from 'react';
import Button from '../Button';
import ButtonIcon from '../ButtonIcon';
import {BridgeContext, StoreContext} from '../context';
import {useSubscription} from '../hooks';

type SubscriptionData = {
  recordChangeDescriptions: boolean,
  supportsReloadAndProfile: boolean,
};

export default function ReloadAndProfileButton({
  disabled,
}: {
  disabled: boolean,
}): React.Node {
  const bridge = useContext(BridgeContext);
  const store = useContext(StoreContext);

  const subscription = useMemo(
    () => ({
      getCurrentValue: () => ({
        recordChangeDescriptions: store.recordChangeDescriptions,
        supportsReloadAndProfile: store.supportsReloadAndProfile,
      }),
      subscribe: (callback: Function) => {
        store.addListener('recordChangeDescriptions', callback);
        store.addListener('supportsReloadAndProfile', callback);
        return () => {
          store.removeListener('recordChangeDescriptions', callback);
          store.removeListener('supportsReloadAndProfile', callback);
        };
      },
    }),
    [store],
  );
  const {recordChangeDescriptions, supportsReloadAndProfile} =
    useSubscription<SubscriptionData>(subscription);

  const reloadAndProfile = useCallback(() => {
    // TODO If we want to support reload-and-profile for e.g. React Native,
    // we might need to also start profiling here before reloading the app (since DevTools itself isn't reloaded).
    // We'd probably want to do this before reloading though, to avoid sending a message on a disconnected port in the browser.
    // For now, let's just skip doing it entirely to avoid paying snapshot costs for data we don't need.
    // startProfiling();

    bridge.send('reloadAndProfile', {
      recordChangeDescriptions,
      recordTimeline: store.supportsTimeline,
    });
  }, [bridge, recordChangeDescriptions, store]);

  if (!supportsReloadAndProfile) {
    return null;
  }

  return (
    <Button
      disabled={disabled}
      onClick={reloadAndProfile}
      title="Reload and start profiling">
      <ButtonIcon type="reload" />
    </Button>
  );
}

Domain

Subdomains

Frequently Asked Questions

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