Home / File/ EditorImpl.tsx — react Source File

EditorImpl.tsx — react Source File

Architecture documentation for EditorImpl.tsx, a tsx file in the react codebase. 12 imports, 0 dependents.

File tsx MonacoIntegration Options 12 imports 1 functions

Entity Profile

Dependency Diagram

graph LR
  6c4ddf93_cf1a_7b66_fd69_69c7c8032b25["EditorImpl.tsx"]
  73168655_c854_d3d1_50a0_b37f865f3c7e["StoreContext.tsx"]
  6c4ddf93_cf1a_7b66_fd69_69c7c8032b25 --> 73168655_c854_d3d1_50a0_b37f865f3c7e
  84f17a2e_0d58_9d14_2c35_30f086f6e436["ConfigEditor.tsx"]
  6c4ddf93_cf1a_7b66_fd69_69c7c8032b25 --> 84f17a2e_0d58_9d14_2c35_30f086f6e436
  d3ca1f05_dcd5_9348_250d_60c101a7660e["ConfigEditor"]
  6c4ddf93_cf1a_7b66_fd69_69c7c8032b25 --> d3ca1f05_dcd5_9348_250d_60c101a7660e
  e75ba65e_505f_abf4_2928_6f0aefb2fc72["Input.tsx"]
  6c4ddf93_cf1a_7b66_fd69_69c7c8032b25 --> e75ba65e_505f_abf4_2928_6f0aefb2fc72
  99f7f91e_9a0f_2ee9_8e38_6383bf6ab909["Input"]
  6c4ddf93_cf1a_7b66_fd69_69c7c8032b25 --> 99f7f91e_9a0f_2ee9_8e38_6383bf6ab909
  034b2d8c_7261_f40f_c380_2b5db8fde033["Output.tsx"]
  6c4ddf93_cf1a_7b66_fd69_69c7c8032b25 --> 034b2d8c_7261_f40f_c380_2b5db8fde033
  66c59e09_c502_e2a2_c5ac_0a4d7c7552eb["CompilerOutput"]
  6c4ddf93_cf1a_7b66_fd69_69c7c8032b25 --> 66c59e09_c502_e2a2_c5ac_0a4d7c7552eb
  9ba26589_c539_da05_fcd2_2ca7851645ba["compilation.ts"]
  6c4ddf93_cf1a_7b66_fd69_69c7c8032b25 --> 9ba26589_c539_da05_fcd2_2ca7851645ba
  01f84d19_40f4_ddcb_bf42_a422f8d05d88["compile"]
  6c4ddf93_cf1a_7b66_fd69_69c7c8032b25 --> 01f84d19_40f4_ddcb_bf42_a422f8d05d88
  33e3aca7_66ee_ce27_72ad_b6d7fb17e06c["babel-plugin-react-compiler"]
  6c4ddf93_cf1a_7b66_fd69_69c7c8032b25 --> 33e3aca7_66ee_ce27_72ad_b6d7fb17e06c
  ac587885_e294_a1e9_b13f_5e7b920fdb42["react"]
  6c4ddf93_cf1a_7b66_fd69_69c7c8032b25 --> ac587885_e294_a1e9_b13f_5e7b920fdb42
  e81931c0_5405_5b82_9cf3_d6fb6fe2fe65["pretty-format"]
  6c4ddf93_cf1a_7b66_fd69_69c7c8032b25 --> e81931c0_5405_5b82_9cf3_d6fb6fe2fe65
  style 6c4ddf93_cf1a_7b66_fd69_69c7c8032b25 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.
 */

import {
  CompilerErrorDetail,
  CompilerDiagnostic,
} from 'babel-plugin-react-compiler';
import {useDeferredValue, useMemo, useState} from 'react';
import {useStore} from '../StoreContext';
import ConfigEditor from './ConfigEditor';
import Input from './Input';
import {CompilerOutput, default as Output} from './Output';
import {compile} from '../../lib/compilation';
import prettyFormat from 'pretty-format';

export default function Editor(): JSX.Element {
  const store = useStore();
  const deferredStore = useDeferredValue(store);
  const [compilerOutput, language, appliedOptions] = useMemo(
    () => compile(deferredStore.source, 'compiler', deferredStore.config),
    [deferredStore.source, deferredStore.config],
  );
  const [linterOutput] = useMemo(
    () => compile(deferredStore.source, 'linter', deferredStore.config),
    [deferredStore.source, deferredStore.config],
  );
  const [formattedAppliedConfig, setFormattedAppliedConfig] = useState('');

  let mergedOutput: CompilerOutput;
  let errors: Array<CompilerErrorDetail | CompilerDiagnostic>;
  if (compilerOutput.kind === 'ok') {
    errors = linterOutput.kind === 'ok' ? [] : linterOutput.error.details;
    mergedOutput = {
      ...compilerOutput,
      errors,
    };
  } else {
    mergedOutput = compilerOutput;
    errors = compilerOutput.error.details;
  }

  if (appliedOptions) {
    const formatted = prettyFormat(appliedOptions, {
      printFunctionName: false,
      printBasicPrototype: false,
    });
    if (formatted !== formattedAppliedConfig) {
      setFormattedAppliedConfig(formatted);
    }
  }

  return (
    <>
      <div className="relative flex top-14">
        <div className="flex-shrink-0">
          <ConfigEditor formattedAppliedConfig={formattedAppliedConfig} />
        </div>
        <div className="flex flex-1 min-w-0">
          <Input language={language} errors={errors} />
          <Output store={deferredStore} compilerOutput={mergedOutput} />
        </div>
      </div>
    </>
  );
}

Subdomains

Functions

Frequently Asked Questions

What does EditorImpl.tsx do?
EditorImpl.tsx is a source file in the react codebase, written in tsx. It belongs to the MonacoIntegration domain, Options subdomain.
What functions are defined in EditorImpl.tsx?
EditorImpl.tsx defines 1 function(s): Editor.
What does EditorImpl.tsx depend on?
EditorImpl.tsx imports 12 module(s): CompilerOutput, ConfigEditor, ConfigEditor.tsx, Input, Input.tsx, Output.tsx, StoreContext.tsx, babel-plugin-react-compiler, and 4 more.
Where is EditorImpl.tsx in the architecture?
EditorImpl.tsx is located at compiler/apps/playground/components/Editor/EditorImpl.tsx (domain: MonacoIntegration, subdomain: Options, directory: compiler/apps/playground/components/Editor).

Analyze Your Own Codebase

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

Try Supermodel Free