Skip to content

Instantly share code, notes, and snippets.

@satishbabariya
Created May 15, 2019 17:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save satishbabariya/f6e1be1ac5042989e04708274710c2ca to your computer and use it in GitHub Desktop.
Save satishbabariya/f6e1be1ac5042989e04708274710c2ca to your computer and use it in GitHub Desktop.
import * as React from "react";
import * as monaco from 'monaco-editor-core/esm/vs/editor/editor.main';
// (self as any).MonacoEnvironment = {
// getWorkerUrl: () => './editor.worker.bundle.js',
// };
class Editor extends React.Component {
node = React.createRef<HTMLDivElement>();
editor: monaco.editor.IStandaloneCodeEditor | null = null;
componentDidMount() {
this.editor = monaco.editor.create(this.node.current as HTMLDivElement, {
language: "typescript"
});
}
componentWillUnmount() {
this.editor && this.editor.dispose();
}
render() {
return (
<div ref={this.node} style={{ width: '100px', height: '100px'}} />
);
}
}
export default Editor;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment