Skip to content

Commit

Permalink
Skip React frames that are too close
Browse files Browse the repository at this point in the history
  • Loading branch information
gaearon committed May 14, 2017
1 parent 76d2d84 commit 13da107
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions packages/react-error-overlay/src/utils/warnings.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,26 @@ function massage(

// Reassemble the stack with full filenames provided by React
let stack = '';
let lastFilename;
let lastLineNumber;
for (let index = 0; index < frames.length; ++index) {
const { fileName, lineNumber } = frames[index];
if (fileName == null || lineNumber == null) {
continue;
}

// TODO: instead, collapse them in the UI
if (
fileName === lastFilename &&
typeof lineNumber === 'number' &&
typeof lastLineNumber === 'number' &&
Math.abs(lineNumber - lastLineNumber) < 3
) {
continue;
}
lastFilename = fileName;
lastLineNumber = lineNumber;

let { functionName } = frames[index];
functionName = functionName || '(anonymous function)';
stack += `in ${functionName} (at ${fileName}:${lineNumber})\n`;
Expand Down

0 comments on commit 13da107

Please sign in to comment.