diff --git a/packages/abc/reuse-tab/reuse-tab.service.ts b/packages/abc/reuse-tab/reuse-tab.service.ts index 28ddca363..a1de281d8 100644 --- a/packages/abc/reuse-tab/reuse-tab.service.ts +++ b/packages/abc/reuse-tab/reuse-tab.service.ts @@ -475,8 +475,6 @@ export class ReuseTabService implements OnDestroy { */ store(_snapshot: ActivatedRouteSnapshot, _handle: NzSafeAny): void { const url = this.getUrl(_snapshot); - const idx = this.index(url); - if (idx === -1) return; if (_handle != null) { this.saveCache(_snapshot, _handle); @@ -492,9 +490,11 @@ export class ReuseTabService implements OnDestroy { _snapshot, _handle }; + + const idx = this.index(url); // Current handler is null when activate routes // For better reliability, we need to wait for the component to be attached before call _onReuseInit - const cahcedComponentRef = list[idx]._handle?.componentRef; + const cahcedComponentRef = list[idx]?._handle?.componentRef; if (_handle == null && cahcedComponentRef != null) { timer(100) .pipe(take(1))