Skip to content
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

fix: only inject overlay in development mode and when window is defined #146

Merged
merged 1 commit into from
Jul 18, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 14 additions & 11 deletions client/ErrorOverlayEntry.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,17 @@ function compileMessageHandler(message) {
}
}

// Registers handlers for compile errors
__react_refresh_init_socket__(compileMessageHandler, __resourceQuery);
// Registers handlers for runtime errors
errorEventHandlers.error(function handleError(error) {
hasRuntimeErrors = true;
__react_refresh_error_overlay__.handleRuntimeError(error);
});
errorEventHandlers.unhandledRejection(function handleUnhandledPromiseRejection(error) {
hasRuntimeErrors = true;
__react_refresh_error_overlay__.handleRuntimeError(error);
});
// Only register if we're in production mode and if window is defined
if (process.env.NODE_ENV !== 'production' && typeof window !== 'undefined') {
// Registers handlers for compile errors
__react_refresh_init_socket__(compileMessageHandler, __resourceQuery);
// Registers handlers for runtime errors
errorEventHandlers.error(function handleError(error) {
hasRuntimeErrors = true;
__react_refresh_error_overlay__.handleRuntimeError(error);
});
errorEventHandlers.unhandledRejection(function handleUnhandledPromiseRejection(error) {
hasRuntimeErrors = true;
__react_refresh_error_overlay__.handleRuntimeError(error);
});
}