Skip to content

Commit 883512b

Browse files
committed
Reload the page when an error has occurred
Fixes facebook#3096
1 parent fcb6dc5 commit 883512b

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

packages/react-dev-utils/webpackHotDevClient.js

+12-3
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,18 @@ var ErrorOverlay = require('react-error-overlay');
2828
ErrorOverlay.startReportingRuntimeErrors({
2929
launchEditorEndpoint: launchEditorEndpoint,
3030
onError: function() {
31-
// TODO: why do we need this?
32-
if (module.hot && typeof module.hot.decline === 'function') {
33-
module.hot.decline();
31+
// Ensure HotModuleReplacementPlugin is active
32+
if (module.hot && typeof module.hot.addStatusHandler === 'function') {
33+
// When a run time error occurs, it does not make sense to continue HMR;
34+
// as application state may be corrupted.
35+
// So, next time we check for updates, simply reload the page (to
36+
// abort the process).
37+
// See https://github.com/facebookincubator/create-react-app/issues/3096
38+
module.hot.addStatusHandler(function(status) {
39+
if (status === 'check') {
40+
window.location.reload();
41+
}
42+
});
3443
}
3544
},
3645
filename: '/static/js/bundle.js',

0 commit comments

Comments
 (0)