Skip to content

Commit 3956ffe

Browse files
jseminckCompuIves
authored andcommitted
Fix issue when clicking prettify when the sandbox contains syntax errors (codesandbox#186)
* Check that newCode is actually defined before switching the output * Remove console log * Fix prettier
1 parent d0bb090 commit 3956ffe

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/app/components/sandbox/CodeEditor/CodeMirror.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,7 @@ export default class CodeEditor extends React.PureComponent<Props, State> {
442442
preferences.prettierConfig
443443
);
444444

445-
if (newCode !== code) {
445+
if (newCode && newCode !== code) {
446446
this.props.changeCode(id, newCode);
447447
this.updateCodeMirrorCode(newCode);
448448
}

src/app/components/sandbox/CodeEditor/Monaco.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -736,7 +736,7 @@ export default class CodeEditor extends React.PureComponent<Props, State> {
736736
preferences.prettierConfig
737737
);
738738

739-
if (newCode !== code) {
739+
if (newCode && newCode !== code) {
740740
this.props.changeCode(id, newCode);
741741
this.updateCode(newCode);
742742
}

0 commit comments

Comments
 (0)