@@ -351,7 +351,7 @@ function asyncComponent(config) {
351
351
// so the mount call will not happen (but the ctor does).
352
352
var _this = _possibleConstructorReturn ( this , ( AsyncComponent . __proto__ || Object . getPrototypeOf ( AsyncComponent ) ) . call ( this , props , context ) ) ;
353
353
354
- if ( _this . context . asyncComponents && ! sharedState . id ) {
354
+ if ( _this . context . asyncComponents != null && ! sharedState . id ) {
355
355
sharedState . id = _this . context . asyncComponents . getNextId ( ) ;
356
356
}
357
357
return _this ;
@@ -382,14 +382,16 @@ function asyncComponent(config) {
382
382
}
383
383
384
384
// node
385
- var isChildOfBoundary = asyncComponentsAncestor && asyncComponentsAncestor . isBoundary ;
385
+ var isChildOfBoundary = asyncComponentsAncestor != null && asyncComponentsAncestor . isBoundary ;
386
386
return serverMode === 'defer' || isChildOfBoundary ? false : doResolve ( ) ;
387
387
}
388
388
} , {
389
389
key : 'getChildContext' ,
390
390
value : function getChildContext ( ) {
391
- if ( ! this . context . asyncComponents ) {
392
- return undefined ;
391
+ if ( this . context . asyncComponents == null ) {
392
+ return {
393
+ asyncComponentsAncestor : null
394
+ } ;
393
395
}
394
396
395
397
return {
@@ -411,10 +413,15 @@ function asyncComponent(config) {
411
413
} , {
412
414
key : 'componentDidMount' ,
413
415
value : function componentDidMount ( ) {
414
- if ( ! this . state . module ) {
416
+ if ( this . shouldResolve ( ) ) {
415
417
this . resolveModule ( ) ;
416
418
}
417
419
}
420
+ } , {
421
+ key : 'shouldResolve' ,
422
+ value : function shouldResolve ( ) {
423
+ return sharedState . module == null && sharedState . error == null && ! this . resolving && typeof window !== 'undefined' ;
424
+ }
418
425
} , {
419
426
key : 'resolveModule' ,
420
427
value : function resolveModule ( ) {
@@ -426,7 +433,7 @@ function asyncComponent(config) {
426
433
if ( _this3 . unmounted ) {
427
434
return undefined ;
428
435
}
429
- if ( _this3 . context . asyncComponents ) {
436
+ if ( _this3 . context . asyncComponents != null ) {
430
437
_this3 . context . asyncComponents . resolved ( sharedState . id ) ;
431
438
}
432
439
sharedState . module = module ;
@@ -482,7 +489,6 @@ function asyncComponent(config) {
482
489
module = _state . module ,
483
490
error = _state . error ;
484
491
485
-
486
492
if ( error ) {
487
493
return ErrorComponent ? _react2 . default . createElement ( ErrorComponent , _extends ( { } , this . props , { error : error } ) ) : null ;
488
494
}
@@ -491,7 +497,7 @@ function asyncComponent(config) {
491
497
// RHL the local component reference will be killed by any change
492
498
// to the component, this will be our signal to know that we need to
493
499
// re-resolve it.
494
- if ( sharedState . module == null && ! this . resolving && typeof window !== 'undefined' ) {
500
+ if ( this . shouldResolve ( ) ) {
495
501
this . resolveModule ( ) ;
496
502
}
497
503
0 commit comments