Code.js — react Source File
Architecture documentation for Code.js, a javascript file in the react codebase. 2 imports, 1 dependents.
Entity Profile
Dependency Diagram
graph LR 58e434e3_34f3_a439_db07_90934d2ad3e4["Code.js"] f8429146_1d45_26dd_090f_7c5376f684ab["find-dom-node.js"] 58e434e3_34f3_a439_db07_90934d2ad3e4 --> f8429146_1d45_26dd_090f_7c5376f684ab 6a16ba39_67e4_1613_55b4_346b67d822dd["findDOMNode"] 58e434e3_34f3_a439_db07_90934d2ad3e4 --> 6a16ba39_67e4_1613_55b4_346b67d822dd 24f91f3d_8b7d_3d1b_d51b_544e9e2c6143["index.js"] 24f91f3d_8b7d_3d1b_d51b_544e9e2c6143 --> 58e434e3_34f3_a439_db07_90934d2ad3e4 style 58e434e3_34f3_a439_db07_90934d2ad3e4 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
import {findDOMNode} from '../../../find-dom-node';
const React = window.React;
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}
/>
);
}
}
/**
* Prevent IE9 from raising an error on an unrecognized element:
* See https://github.com/facebook/react/issues/13610
*/
const supportsDetails = !(
document.createElement('details') instanceof HTMLUnknownElement
);
export class CodeError extends React.Component {
render() {
const {error, className} = this.props;
if (!error) {
return null;
}
if (supportsDetails) {
const [summary, ...body] = error.message.split(/\n+/g);
if (body.length >= 0) {
return <div className={className}>{summary}</div>;
}
return (
<details className={className}>
<summary>{summary}</summary>
{body.join('\n')}
</details>
);
}
return <div className={className}>{error.message}</div>;
}
}
Domain
Subdomains
Classes
Dependencies
Source
Frequently Asked Questions
What does Code.js do?
Code.js is a source file in the react codebase, written in javascript. It belongs to the BabelCompiler domain, Optimization subdomain.
What does Code.js depend on?
Code.js imports 2 module(s): find-dom-node.js, findDOMNode.
What files import Code.js?
Code.js is imported by 1 file(s): index.js.
Where is Code.js in the architecture?
Code.js is located at fixtures/dom/src/components/fixtures/hydration/Code.js (domain: BabelCompiler, subdomain: Optimization, directory: fixtures/dom/src/components/fixtures/hydration).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free