Skip to content

RouterExtension navigating back causes crash #1160

Open
@TheOnlyMatt

Description

@TheOnlyMatt

Hello,

I am currently facing an issue when I want to navigate back to my main page.
Here is my code :

MAIN PAGE

constructor(private routerExtensions : RouterExtensions)

ngOnInit(): void {

       //Ouvre le tutoriel à la première ouverture de l'application
       this._userInfo.checkFirstOpening().then(value => {
           if(value != true){
               console.log("opening tuto")
               this.routerExtensions.navigate(["/tutorial"],  {
                   transition: {
                       name: "fade",
                       duration: 300
                   }
               })
           }
           else
               console.log("not first launch")
       })
}

CHILD PAGE

import { RouterExtensions } from "nativescript-angular/router";

export class TutorialComponent implements OnInit{
 constructor( private routerExtensions : RouterExtensions, private page: Page) {}

    closeView(){
        console.log("going back")
        this.routerExtensions.backToPreviousPage();
    }
}

So my tutorial component is well opened after the navigation from the main page.
But when I want to go back from the tutorial page to the main page, I have a blank screen, and this error in logs :

CONSOLE ERROR file:///app/tns_modules/@angular/core/./bundles/core.umd.js:1466:24: ERROR Error: Uncaught (in promise): TypeError: undefined is not an object (evaluating 'this.cache.peek().key')
        shouldAttach@file:///app/tns_modules/nativescript-angular/router/ns-route-reuse-strategy.js:67:55
        activateRoutes@file:///app/tns_modules/@angular/router/./bundles/router.umd.js:5741:57
        file:///app/tns_modules/@angular/router/./bundles/router.umd.js:5702:33
        forEach@[native code]
        activateChildRoutes@file:///app/tns_modules/@angular/router/./bundles/router.umd.js:5701:36
        activate@file:///app/tns_modules/@angular/router/./bundles/router.umd.js:5561:33
        file:///app/tns_modules/@angular/router/./bundles/router.umd.js:5474:30
        file:///app/tns_modules/rxjs/Observable.js:225:25
        __tryOrSetError@file:///app/tns_modules/rxjs/Subscriber.js:248:20
...

No matter if I do "backToPreviousPage()" or simply "back()" the crash occurs.
When doing this.routerExtensions.canGoBack(), I receive false, as if I was not allowed to navigate back.

Why is this happening, while I am not event clearing the navigation history on first navigate ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions