From 53c692a7066ef0a4378cd3b13eeee586732a7016 Mon Sep 17 00:00:00 2001 From: Garth Smedley Date: Sat, 3 Mar 2018 12:23:17 -0400 Subject: [PATCH] See: https://github.com/NativeScript/nativescript-angular/issues/1048 using the same check for an empty cache as used in the retrieve() method. --- nativescript-angular/router/ns-route-reuse-strategy.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/nativescript-angular/router/ns-route-reuse-strategy.ts b/nativescript-angular/router/ns-route-reuse-strategy.ts index d6b489180..e893e7f26 100644 --- a/nativescript-angular/router/ns-route-reuse-strategy.ts +++ b/nativescript-angular/router/ns-route-reuse-strategy.ts @@ -79,7 +79,8 @@ export class NSRouteReuseStrategy implements RouteReuseStrategy { const key = getSnapshotKey(route); const isBack = this.location._isPageNavigatingBack(); - const shouldAttach = isBack && this.cache.peek().key === key; + const cachedItem = this.cache.peek(); + const shouldAttach = isBack && cachedItem && cachedItem.key === key; log(`shouldAttach isBack: ${isBack} key: ${key} result: ${shouldAttach}`);