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

Commit

Permalink
add function to check for console object or props (#5780)
Browse files Browse the repository at this point in the history
* add function to check for console object or props

* fix flow
  • Loading branch information
bomsy authored and jasonLaster committed Mar 26, 2018
1 parent 27b94fb commit e8f5b84
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/actions/preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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));
};
}
Expand Down
4 changes: 4 additions & 0 deletions src/utils/preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,7 @@ export function isReactComponent(result: Grip) {
Object.keys(ownProperties).includes("_reactInternalFiber")
);
}

export function isConsole(expression: string) {
return /^console/.test(expression);
}

0 comments on commit e8f5b84

Please sign in to comment.