Created
April 14, 2019 12:51
-
-
Save amazzalel-habib/bc332452b579b6cae6c2234594713b8d 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'; | |
interface IEditorPorps { | |
language: string; | |
} | |
const Editor: React.FC<IEditorPorps> = (props: IEditorPorps) => { | |
let divNode; | |
const assignRef = React.useCallback((node) => { | |
// On mount get the ref of the div and assign it the divNode | |
divNode = node; | |
}, []); | |
React.useEffect(() => { | |
if (divNode) { | |
const editor = monaco.editor.create(divNode, { | |
language: props.language, | |
minimap: { enabled: false }, | |
autoIndent: true | |
}); | |
} | |
}, [assignRef]) | |
return <div ref={assignRef} style={{ height: '90vh' }}></div>; | |
} | |
export { Editor }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment