Skip to content
This repository was archived by the owner on Jan 11, 2023. It is now read-only.

Commit e8f5b84

Browse files
bomsyjasonLaster
authored andcommitted
add function to check for console object or props (#5780)
* add function to check for console object or props * fix flow
1 parent 27b94fb commit e8f5b84

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

src/actions/preview.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
import { findBestMatchExpression } from "../utils/ast";
88
import { getTokenLocation } from "../utils/editor";
9-
import { isReactComponent, isImmutable } from "../utils/preview";
9+
import { isReactComponent, isImmutable, isConsole } from "../utils/preview";
1010
import { isGeneratedId } from "devtools-source-map";
1111
import { PROMISE } from "./utils/middleware/promise";
1212
import { getExpressionFromCoords } from "../utils/editor/get-expression";
@@ -136,6 +136,11 @@ export function updatePreview(target: HTMLElement, editor: any) {
136136
}
137137

138138
const { expression, location } = match;
139+
140+
if (isConsole(expression)) {
141+
return;
142+
}
143+
139144
dispatch(setPreview(expression, location, tokenPos, cursorPos));
140145
};
141146
}

src/utils/preview.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,7 @@ export function isReactComponent(result: Grip) {
3838
Object.keys(ownProperties).includes("_reactInternalFiber")
3939
);
4040
}
41+
42+
export function isConsole(expression: string) {
43+
return /^console/.test(expression);
44+
}

0 commit comments

Comments
 (0)