Skip to content

Commit

Permalink
Reload the page when an error has occurred
Browse files Browse the repository at this point in the history
  • Loading branch information
Timer committed Sep 8, 2017
1 parent fcb6dc5 commit 883512b
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions packages/react-dev-utils/webpackHotDevClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,18 @@ var ErrorOverlay = require('react-error-overlay');
ErrorOverlay.startReportingRuntimeErrors({
launchEditorEndpoint: launchEditorEndpoint,
onError: function() {
// TODO: why do we need this?
if (module.hot && typeof module.hot.decline === 'function') {
module.hot.decline();
// Ensure HotModuleReplacementPlugin is active
if (module.hot && typeof module.hot.addStatusHandler === 'function') {
// When a run time error occurs, it does not make sense to continue HMR;
// as application state may be corrupted.
// So, next time we check for updates, simply reload the page (to
// abort the process).
// See https://github.com/facebookincubator/create-react-app/issues/3096
module.hot.addStatusHandler(function(status) {
if (status === 'check') {
window.location.reload();
}
});
}
},
filename: '/static/js/bundle.js',
Expand Down

0 comments on commit 883512b

Please sign in to comment.