Created
May 15, 2019 17:43
-
-
Save satishbabariya/f6e1be1ac5042989e04708274710c2ca to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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