-
-
Notifications
You must be signed in to change notification settings - Fork 27k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add warning when using react-error-overlay
in production
#3264
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -167,3 +167,24 @@ window.__REACT_ERROR_OVERLAY_GLOBAL_HOOK__.iframeReady = function iframeReady() | |
isLoadingIframe = false; | ||
updateIframeContent(); | ||
}; | ||
|
||
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) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I suppose this would probably error out if they did not envify variables, so I agree. |
||
console.warn( | ||
'It looks like you are using `react-error-overlay` in production. ' + | ||
warningText | ||
); | ||
} | ||
} else { | ||
console.warn( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe this could be more severe with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. IMO it makes more sense to go with |
||
'You are using `react-error-overlay` in production. ' + warningText | ||
); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need the error boundary text here? Doesn't seem very relevant.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If someone was purposely including
react-error-overlay
for production errors, though I know most cases would be accidental.We can remove this.