Skip to content

Commit f72087c

Browse files
committed
Improve performance of typing in editor
Previously we would rerender Content on every keypress, because of `state.editor.isAllModulesSynced`.This check uses `sandbox.modules`, so the component updates on everycode change. Content is quite expensive. The solution is to remove the component because this is handled in overmind.
1 parent 5a205c1 commit f72087c

File tree

1 file changed

+2
-10
lines changed
  • packages/app/src/app/pages/Sandbox/Editor/Content

1 file changed

+2
-10
lines changed

packages/app/src/app/pages/Sandbox/Editor/Content/index.tsx

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,13 @@ import { DevTools } from 'app/components/Preview/DevTools';
66
import { useOvermind } from 'app/overmind';
77
import React, { useCallback, useEffect, useRef } from 'react';
88
import QuestionIcon from 'react-icons/lib/go/question';
9-
import { Prompt } from 'react-router-dom';
109
import SplitPane from 'react-split-pane';
1110
import { ThemeProvider } from 'styled-components';
1211

1312
import preventGestureScroll, { removeListener } from './prevent-gesture-scroll';
1413
import { Preview } from './Preview';
1514

16-
export const Content: React.FC = () => {
15+
export const MainWorkspace: React.FC = () => {
1716
const { state, actions, effects, reaction } = useOvermind();
1817
const editorEl = useRef(null);
1918
const contentEl = useRef(null);
@@ -59,7 +58,6 @@ export const Content: React.FC = () => {
5958
}, [actions.editor, effects.vscode, reaction, updateEditorSize]);
6059

6160
const { currentModule } = state.editor;
62-
const notSynced = !state.editor.isAllModulesSynced;
6361
const sandbox = state.editor.currentSandbox;
6462
const { preferences } = state;
6563
const windowVisible = state.editor.previewWindowVisible;
@@ -104,12 +102,6 @@ export const Content: React.FC = () => {
104102
}}
105103
ref={contentEl}
106104
>
107-
<Prompt
108-
when={notSynced && !state.editor.isForkingSandbox}
109-
message={() =>
110-
'You have not saved this sandbox, are you sure you want to navigate away?'
111-
}
112-
/>
113105
<SplitPane
114106
maxSize={-100}
115107
onDragFinished={() => {
@@ -246,4 +238,4 @@ export const Content: React.FC = () => {
246238
);
247239
};
248240

249-
export default Content;
241+
export default MainWorkspace;

0 commit comments

Comments
 (0)