You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
bug: Ionic life cycle hooks are not triggering in routed component #30644
I have searched for existing issues that already report this problem, without success.
Ionic Framework Version
v8.x
Current Behavior
"When I navigate from A(III) to B and then back to A(III), the Ionic lifecycle hooks inside A(III) are not being called, but the lifecycle hooks of Page A are being triggered.
Expected Behavior
Expecting Life cycle hooks in page A (III) to be triggered.
Steps to Reproduce
Note: Please keep browser console open to view the logs
Go to page A (Now, in my demo application it will navigate to page A(III) by default in page A)
Now from A(III), go to page B
Now go back with browser back navigation to page A(III)
Now, If you see the browser you can only see page A ionViewWillEnter is only being triggered, but page A(III) ionViewWillEnter didn't triggered
We are experiencing the same issue throughout our entire application, and it is impacting major functionalities by causing frontend inconsistencies, as hooks are deeply integrated.
Verified on 9.0.8, where this is fixed by #31532, released in v9.0.8. When you go from A(III) to B and back, the root ion-router-outlet transitions Page A, but the nested ion-router-outlet inside Page A never transitions, because A(III) was its active page the whole time. Ionic only fired lifecycle events on the page being transitioned, so A(III) received neither the enter events on the way back nor the leave events on the way out. From 9.0.8, the nested outlet forwards Page A's lifecycle events to its active page.
If you can't move to 9.x yet, re-dispatch Page A's events onto the nested outlet's active page. This was verified on 8.8.19, and it is safe to keep after upgrading, since 9.0.8 detects the re-dispatch and does not fire the events twice:
import{Component,ViewChild}from'@angular/core';import{IonRouterOutlet}from'@ionic/angular';
@Component({selector: 'app-page-a',template: '<ion-router-outlet></ion-router-outlet>',standalone: false,})exportclassPageAComponent{
@ViewChild(IonRouterOutlet)outlet!: IonRouterOutlet;privatechildLeft=false;ionViewWillEnter(){this.forward('ionViewWillEnter');}ionViewDidEnter(){this.forward('ionViewDidEnter');}ionViewWillLeave(){this.forward('ionViewWillLeave');}ionViewDidLeave(){this.forward('ionViewDidLeave');}privateforward(eventName: string){// On first entry the nested outlet already fired enter on its own page.if(eventName.endsWith('Enter')&&!this.childLeft){return;}this.outlet.getLastRouteView()?.element.dispatchEvent(newCustomEvent(eventName));if(eventName==='ionViewDidLeave'){this.childLeft=true;}if(eventName==='ionViewDidEnter'){this.childLeft=false;}}}
The childLeft check matters: without it, A(III) gets its enter events twice the first time you open Page A.
Closing this as completed, since the fix is in 9.0.8.
Activity
Av1nag commentedon Aug 20, 2025
Let me know if needed any clarification. I'm always here to help.
Praise-99 commentedon Aug 24, 2025
We are experiencing the same issue throughout our entire application, and it is impacting major functionalities by causing frontend inconsistencies, as hooks are deeply integrated.
Av1nag commentedon Aug 28, 2025
Hi @brandyscarney ,
May I know any updates regarding this issue?
thetaPC commentedon Oct 16, 2026
Thanks for the report, and sorry for the delay.
Verified on 9.0.8, where this is fixed by #31532, released in v9.0.8. When you go from A(III) to B and back, the root
ion-router-outlettransitions Page A, but the nestedion-router-outletinside Page A never transitions, because A(III) was its active page the whole time. Ionic only fired lifecycle events on the page being transitioned, so A(III) received neither the enter events on the way back nor the leave events on the way out. From 9.0.8, the nested outlet forwards Page A's lifecycle events to its active page.If you can't move to 9.x yet, re-dispatch Page A's events onto the nested outlet's active page. This was verified on 8.8.19, and it is safe to keep after upgrading, since 9.0.8 detects the re-dispatch and does not fire the events twice:
The
childLeftcheck matters: without it, A(III) gets its enter events twice the first time you open Page A.Closing this as completed, since the fix is in 9.0.8.