Home / File/ index.js — react Source File

index.js — react Source File

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

File javascript CompilerCore Gating 1 imports 1 dependents 4 functions

Entity Profile

Dependency Diagram

graph LR
  c5a02f6f_1fe4_38a9_b2db_d59beb75c9a9["index.js"]
  c745ba00_63aa_6e9b_0885_a745bade6cf7["react"]
  c5a02f6f_1fe4_38a9_b2db_d59beb75c9a9 --> c745ba00_63aa_6e9b_0885_a745bade6cf7
  34ac7c0b_f4e9_b2d5_8835_432c386eab1e["index.js"]
  34ac7c0b_f4e9_b2d5_8835_432c386eab1e --> c5a02f6f_1fe4_38a9_b2db_d59beb75c9a9
  style c5a02f6f_1fe4_38a9_b2db_d59beb75c9a9 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 {useRef, useState} from 'react';

const Counter = () => {
  const [count, setCount] = useState(0);

  return (
    <div>
      <h3>Count: {count}</h3>
      <button onClick={() => setCount(c => c + 1)}>Increment</button>
    </div>
  );
};

function DialogComponent() {
  const dialogRef = useRef(null);

  const openDialog = () => {
    if (dialogRef.current) {
      dialogRef.current.showModal();
    }
  };

  const closeDialog = () => {
    if (dialogRef.current) {
      dialogRef.current.close();
    }
  };

  return (
    <div style={{margin: '10px 0'}}>
      <button onClick={openDialog}>Open Dialog</button>
      <dialog ref={dialogRef} style={{padding: '20px'}}>
        <h3>Dialog Content</h3>
        <Counter />
        <button onClick={closeDialog}>Close</button>
      </dialog>
    </div>
  );
}

function RegularComponent() {
  return (
    <div style={{margin: '10px 0'}}>
      <h3>Regular Component</h3>
      <Counter />
    </div>
  );
}

export default function TraceUpdatesTest(): React.Node {
  return (
    <div>
      <h2>TraceUpdates Test</h2>

      <div style={{marginBottom: '20px'}}>
        <h3>Standard Component</h3>
        <RegularComponent />
      </div>

      <div style={{marginBottom: '20px'}}>
        <h3>Dialog Component (top-layer element)</h3>
        <DialogComponent />
      </div>

      <div
        style={{marginTop: '20px', padding: '10px', border: '1px solid #ddd'}}>
        <h3>How to Test:</h3>
        <ol>
          <li>Open DevTools Components panel</li>
          <li>Enable "Highlight updates when components render" in settings</li>
          <li>Click increment buttons and observe highlights</li>
          <li>Open the dialog and test increments there as well</li>
        </ol>
      </div>
    </div>
  );
}

Domain

Subdomains

Dependencies

  • react

Frequently Asked Questions

What does index.js do?
index.js is a source file in the react codebase, written in javascript. It belongs to the CompilerCore domain, Gating subdomain.
What functions are defined in index.js?
index.js defines 4 function(s): Counter, DialogComponent, RegularComponent, TraceUpdatesTest.
What does index.js depend on?
index.js imports 1 module(s): react.
What files import index.js?
index.js is imported by 1 file(s): index.js.
Where is index.js in the architecture?
index.js is located at packages/react-devtools-shell/src/app/TraceUpdatesTest/index.js (domain: CompilerCore, subdomain: Gating, directory: packages/react-devtools-shell/src/app/TraceUpdatesTest).

Analyze Your Own Codebase

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

Try Supermodel Free