@@ -351,7 +351,7 @@ function asyncComponent(config) {
351351 // so the mount call will not happen (but the ctor does).
352352 var _this = _possibleConstructorReturn ( this , ( AsyncComponent . __proto__ || Object . getPrototypeOf ( AsyncComponent ) ) . call ( this , props , context ) ) ;
353353
354- if ( _this . context . asyncComponents && ! sharedState . id ) {
354+ if ( _this . context . asyncComponents != null && ! sharedState . id ) {
355355 sharedState . id = _this . context . asyncComponents . getNextId ( ) ;
356356 }
357357 return _this ;
@@ -382,14 +382,16 @@ function asyncComponent(config) {
382382 }
383383
384384 // node
385- var isChildOfBoundary = asyncComponentsAncestor && asyncComponentsAncestor . isBoundary ;
385+ var isChildOfBoundary = asyncComponentsAncestor != null && asyncComponentsAncestor . isBoundary ;
386386 return serverMode === 'defer' || isChildOfBoundary ? false : doResolve ( ) ;
387387 }
388388 } , {
389389 key : 'getChildContext' ,
390390 value : function getChildContext ( ) {
391- if ( ! this . context . asyncComponents ) {
392- return undefined ;
391+ if ( this . context . asyncComponents == null ) {
392+ return {
393+ asyncComponentsAncestor : null
394+ } ;
393395 }
394396
395397 return {
@@ -411,10 +413,15 @@ function asyncComponent(config) {
411413 } , {
412414 key : 'componentDidMount' ,
413415 value : function componentDidMount ( ) {
414- if ( ! this . state . module ) {
416+ if ( this . shouldResolve ( ) ) {
415417 this . resolveModule ( ) ;
416418 }
417419 }
420+ } , {
421+ key : 'shouldResolve' ,
422+ value : function shouldResolve ( ) {
423+ return sharedState . module == null && sharedState . error == null && ! this . resolving && typeof window !== 'undefined' ;
424+ }
418425 } , {
419426 key : 'resolveModule' ,
420427 value : function resolveModule ( ) {
@@ -426,7 +433,7 @@ function asyncComponent(config) {
426433 if ( _this3 . unmounted ) {
427434 return undefined ;
428435 }
429- if ( _this3 . context . asyncComponents ) {
436+ if ( _this3 . context . asyncComponents != null ) {
430437 _this3 . context . asyncComponents . resolved ( sharedState . id ) ;
431438 }
432439 sharedState . module = module ;
@@ -482,7 +489,6 @@ function asyncComponent(config) {
482489 module = _state . module ,
483490 error = _state . error ;
484491
485-
486492 if ( error ) {
487493 return ErrorComponent ? _react2 . default . createElement ( ErrorComponent , _extends ( { } , this . props , { error : error } ) ) : null ;
488494 }
@@ -491,7 +497,7 @@ function asyncComponent(config) {
491497 // RHL the local component reference will be killed by any change
492498 // to the component, this will be our signal to know that we need to
493499 // re-resolve it.
494- if ( sharedState . module == null && ! this . resolving && typeof window !== 'undefined' ) {
500+ if ( this . shouldResolve ( ) ) {
495501 this . resolveModule ( ) ;
496502 }
497503
0 commit comments