Skip to content

Commit

Permalink
Add more robust check
Browse files Browse the repository at this point in the history
  • Loading branch information
Timer committed Oct 11, 2017
1 parent 397b5ae commit 2410af7
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions packages/react-error-overlay/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,14 +168,23 @@ window.__REACT_ERROR_OVERLAY_GLOBAL_HOOK__.iframeReady = function iframeReady()
updateIframeContent();
};

var testFunc = function testFn() {};
if ((testFunc.name || testFunc.toString()).indexOf('testFn') !== -1) {
const warningText =
'When deploying an application, `react-error-overlay` should be excluded ' +
'as it is a heavy dependency meant for development.\n\n' +
'Consider adding an error boundary to your tree to customize error ' +
'handling behavior. See https://fb.me/react-error-boundaries for more ' +
'information.';

if (process.env.NODE_ENV !== 'production') {
var testFunc = function testFn() {};
if ((testFunc.name || testFunc.toString()).indexOf('testFn') === -1) {
console.warn(
'It looks like you are using `react-error-overlay` in production. ' +
warningText
);
}
} else {
console.warn(
'It looks like you are using `react-error-overlay` in production. When ' +
'deploying an application, `react-error-overlay` should be excluded ' +
'as it is a heavy dependency meant for development.\n\n' +
'Consider adding an error boundary to your tree to customize error ' +
'handling behavior. See https://fb.me/react-error-boundaries for more ' +
'information.'
'You are using `react-error-overlay` in production. ' + warningText
);
}

0 comments on commit 2410af7

Please sign in to comment.