Skip to content

Commit 1c91071

Browse files
committed
Add an undefined check for MonacoEditor.editor
Fixes codesandbox#2265
1 parent a396a92 commit 1c91071

File tree

1 file changed

+7
-5
lines changed
  • packages/app/src/app/components/CodeEditor/VSCode

1 file changed

+7
-5
lines changed

packages/app/src/app/components/CodeEditor/VSCode/index.tsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,8 @@ class MonacoEditor extends React.Component<Props> implements Editor {
9393
tsconfig: Props['tsconfig'] | undefined;
9494
disposeInitializer?: Function;
9595
lintWorker: Worker | undefined;
96-
editor: any;
97-
monaco: any;
96+
editor?: any;
97+
monaco?: any;
9898
receivingCode: boolean = false;
9999
codeSandboxAPIListener: () => void;
100100
sizeProbeInterval: number | null;
@@ -712,9 +712,11 @@ class MonacoEditor extends React.Component<Props> implements Editor {
712712
'/sandbox' +
713713
getModulePath(this.sandbox.modules, this.sandbox.directories, moduleId);
714714

715-
const modelEditor = this.editor.editorService.editors.find(
716-
editor => editor.resource && editor.resource.path === modulePath
717-
);
715+
const modelEditor =
716+
this.editor &&
717+
this.editor.editorService.editors.find(
718+
editor => editor.resource && editor.resource.path === modulePath
719+
);
718720

719721
// Apply the code to the current module code itself
720722
const module = this.sandbox.modules.find(

0 commit comments

Comments
 (0)