Home / Class/ CodeEditor Class — react Architecture

CodeEditor Class — react Architecture

Architecture documentation for the CodeEditor class in Code.js from the react codebase.

Entity Profile

Dependency Diagram

graph TD
  b9c1fd4b_ff65_7dd6_f605_73afc10be7d6["CodeEditor"]
  58e434e3_34f3_a439_db07_90934d2ad3e4["Code.js"]
  b9c1fd4b_ff65_7dd6_f605_73afc10be7d6 -->|defined in| 58e434e3_34f3_a439_db07_90934d2ad3e4
  b98f1c9f_5bf7_2aab_62a6_5aa27bfb396b["shouldComponentUpdate()"]
  b9c1fd4b_ff65_7dd6_f605_73afc10be7d6 -->|method| b98f1c9f_5bf7_2aab_62a6_5aa27bfb396b
  5daf6956_443d_be4d_ef65_02e90ce88ee0["componentDidMount()"]
  b9c1fd4b_ff65_7dd6_f605_73afc10be7d6 -->|method| 5daf6956_443d_be4d_ef65_02e90ce88ee0
  b9f57d78_6156_689c_1ccb_22fb08523ef3["install()"]
  b9c1fd4b_ff65_7dd6_f605_73afc10be7d6 -->|method| b9f57d78_6156_689c_1ccb_22fb08523ef3
  34ac7107_7602_9cd2_ed58_61d1d9be0349["componentWillUnmount()"]
  b9c1fd4b_ff65_7dd6_f605_73afc10be7d6 -->|method| 34ac7107_7602_9cd2_ed58_61d1d9be0349
  465aa136_6d40_bbe7_fc36_1893d01cddd8["render()"]
  b9c1fd4b_ff65_7dd6_f605_73afc10be7d6 -->|method| 465aa136_6d40_bbe7_fc36_1893d01cddd8

Relationship Graph

Source Code

fixtures/dom/src/components/fixtures/hydration/Code.js lines 5–57

export class CodeEditor extends React.Component {
  shouldComponentUpdate() {
    return false;
  }

  componentDidMount() {
    this.textarea = findDOMNode(this);

    // Important: CodeMirror incorrectly lays out the editor
    // if it executes before CSS has loaded
    // https://github.com/graphql/graphiql/issues/33#issuecomment-318188555
    Promise.all([
      import('codemirror'),
      import('codemirror/mode/jsx/jsx'),
      import('codemirror/lib/codemirror.css'),
      import('./codemirror-paraiso-dark.css'),
    ]).then(([CodeMirror]) => this.install(CodeMirror));
  }

  install(CodeMirror) {
    if (!this.textarea) {
      return;
    }

    const {onChange} = this.props;

    this.editor = CodeMirror.fromTextArea(this.textarea, {
      mode: 'jsx',
      theme: 'paraiso-dark',
      lineNumbers: true,
    });

    this.editor.on('change', function (doc) {
      onChange(doc.getValue());
    });
  }

  componentWillUnmount() {
    if (this.editor) {
      this.editor.toTextArea();
    }
  }

  render() {
    return (
      <textarea
        defaultValue={this.props.code}
        autoComplete="off"
        hidden={true}
      />
    );
  }
}

Domain

Frequently Asked Questions

What is the CodeEditor class?
CodeEditor is a class in the react codebase, defined in fixtures/dom/src/components/fixtures/hydration/Code.js.
Where is CodeEditor defined?
CodeEditor is defined in fixtures/dom/src/components/fixtures/hydration/Code.js at line 5.

Analyze Your Own Codebase

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

Try Supermodel Free