From e8f5b849bd8aeb74506b4f01c4da3fe67ce14119 Mon Sep 17 00:00:00 2001 From: Hubert Boma Manilla Date: Mon, 26 Mar 2018 15:15:34 +0100 Subject: [PATCH] add function to check for console object or props (#5780) * add function to check for console object or props * fix flow --- src/actions/preview.js | 7 ++++++- src/utils/preview.js | 4 ++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/actions/preview.js b/src/actions/preview.js index e91701633a..3e18c24dbd 100644 --- a/src/actions/preview.js +++ b/src/actions/preview.js @@ -6,7 +6,7 @@ import { findBestMatchExpression } from "../utils/ast"; import { getTokenLocation } from "../utils/editor"; -import { isReactComponent, isImmutable } from "../utils/preview"; +import { isReactComponent, isImmutable, isConsole } from "../utils/preview"; import { isGeneratedId } from "devtools-source-map"; import { PROMISE } from "./utils/middleware/promise"; import { getExpressionFromCoords } from "../utils/editor/get-expression"; @@ -136,6 +136,11 @@ export function updatePreview(target: HTMLElement, editor: any) { } const { expression, location } = match; + + if (isConsole(expression)) { + return; + } + dispatch(setPreview(expression, location, tokenPos, cursorPos)); }; } diff --git a/src/utils/preview.js b/src/utils/preview.js index efab5a4f20..1672b668ce 100644 --- a/src/utils/preview.js +++ b/src/utils/preview.js @@ -38,3 +38,7 @@ export function isReactComponent(result: Grip) { Object.keys(ownProperties).includes("_reactInternalFiber") ); } + +export function isConsole(expression: string) { + return /^console/.test(expression); +}