Skip to content

Commit

Permalink
Skip React frames that are too close (facebook#2143)
Browse files Browse the repository at this point in the history
  • Loading branch information
gaearon authored and romaindso committed Jul 10, 2017
1 parent 85bf8fd commit 24ed2cc
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 24ed2cc

Please sign in to comment.