Merge pull request #3390 from tr3ysmith/patch-1

Fix possible duplicate of editors in vite sample
pull/3232/head^2
Henning Dieterichs 2 years ago committed by GitHub
commit c92637e1f1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -7,13 +7,15 @@ export const Editor: VFC = () => {
const monacoEl = useRef(null);
useEffect(() => {
if (monacoEl && !editor) {
setEditor(
monaco.editor.create(monacoEl.current!, {
if (monacoEl) {
setEditor((editor) => {
if (editor) return;
return monaco.editor.create(monacoEl.current!, {
value: ['function x() {', '\tconsole.log("Hello world!");', '}'].join('\n'),
language: 'typescript'
})
);
});
});
}
return () => editor?.dispose();

Loading…
Cancel
Save