File tree Expand file tree Collapse file tree 1 file changed +9
-5
lines changed Expand file tree Collapse file tree 1 file changed +9
-5
lines changed Original file line number Diff line number Diff line change @@ -25,13 +25,17 @@ var launchEditorEndpoint = require('./launchEditorEndpoint');
2525var formatWebpackMessages = require ( './formatWebpackMessages' ) ;
2626var ErrorOverlay = require ( 'react-error-overlay' ) ;
2727
28+ // We need to keep track of if there has been a runtime error.
29+ // Essentially, we cannot guarantee application state was not corrupted by the
30+ // runtime error. To prevent confusing behavior, we forcibly reload the entire
31+ // application. This is handled below when we are notified of a compile (code
32+ // change).
33+ // See https://github.com/facebookincubator/create-react-app/issues/3096
34+ var hadRuntimeError = false ;
2835ErrorOverlay . startReportingRuntimeErrors ( {
2936 launchEditorEndpoint : launchEditorEndpoint ,
3037 onError : function ( ) {
31- // TODO: why do we need this?
32- if ( module . hot && typeof module . hot . decline === 'function' ) {
33- module . hot . decline ( ) ;
34- }
38+ hadRuntimeError = true ;
3539 } ,
3640 filename : '/static/js/bundle.js' ,
3741} ) ;
@@ -227,7 +231,7 @@ function tryApplyUpdates(onHotUpdateSuccess) {
227231 }
228232
229233 function handleApplyUpdates ( err , updatedModules ) {
230- if ( err || ! updatedModules ) {
234+ if ( err || ! updatedModules || hadRuntimeError ) {
231235 window . location . reload ( ) ;
232236 return ;
233237 }
You can’t perform that action at this time.
0 commit comments