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
All of these issue links show the same problem that I am having trouble with. I replaced IonRouterOutlet with Switch, but IonTabs requires IonRouterOutlet, and I must delete IonTabs, and the app looks like ugly.
Probably, the problem is caused by IonRouterOutlet. #20844 #20597 #20298
Duplicate of #20298#20597#20844
For me too... So far the workaround we use is to force a complete page reload (window.location = '...').
But this is definitely ugly, as the whole page flickers and we lose the parent state.
It doesn't work for us.
When using <Switch>, the parent component successfully unmounts, but it also unmounts when it should not (when the path changes but should still keep the parent component mounted), leading to a blank page, without any kind of console error.
Staying with window.location = '...' for now, regarless of how ugly it is.
It doesn't work for us.
When using <Switch>, the parent component successfully unmounts, but it also unmounts when it should not (when the path changes but should still keep the parent component mounted), leading to a blank page, without any kind of console error.
Staying with window.location = '...' for now, regarless of how ugly it is.
Did you try Ionic lifecycle methods?
Especially this one useIonViewDidLeave(() => { console.log('ionViewDidLeave event fired'); });
We have a dev release that provides better support for nested IonRouterOutlet components. There is a new prop on IonRouterOutlet that lets the router know it is a nested outlet to better perform the transition.
If your'e outlet is a nested outlet directly rendered by a Route in a parent outlet, then use the ionPage prop on the IonRouterOutlet. Here is an example:
what is the state on this issue?
Nested routes result in breaking third party libraries (replacing ionRouterOutlet with Switch works)
anyways navigation is crucial
what is the state on this issue?
Nested routes result in breaking third party libraries (replacing ionRouterOutlet with Switch works)
anyways navigation is crucial
You have to remember that replacing IonRouterOutlet with a Switch will mean converting all your useIonViewDidEnter with useEffects and lose animations.
You can set an id to the <IonPage>. When you click the header button, the app will go back and remove your page from the DOM.
This is to force unmount the page, and because this page is no longer on the DOM it cannot execute its life cycles.
This is my helper function
export const removePageFromDOM = (pageId: string) => {
const element = document.getElementById(pageId)
setTimeout(()=>{
return element && element.remove()
}, 1000) // Give a little time to properly unmount your previous page before removing the old one
}
Thanks for the issue! This issue is being closed due to inactivity. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out.
Activity
OoDeLally commentedon Mar 9, 2020
Hi, any news of this?
I've tried to investigate checking the source code, but it seems beyond my level of understanding.
emindeniz99 commentedon Mar 23, 2020
All of these issue links show the same problem that I am having trouble with. I replaced IonRouterOutlet with Switch, but IonTabs requires IonRouterOutlet, and I must delete IonTabs, and the app looks like ugly.
Probably, the problem is caused by IonRouterOutlet.
#20844
#20597
#20298
Duplicate of #20298 #20597 #20844
und3f1ned commentedon Apr 6, 2020
Anybody? This is a huge blocker for me
OoDeLally commentedon Apr 6, 2020
For me too... So far the workaround we use is to force a complete page reload (
window.location = '...').But this is definitely ugly, as the whole page flickers and we lose the parent state.
und3f1ned commentedon Apr 6, 2020
No, God, please, no :) Try this #20707 (comment)
OoDeLally commentedon Apr 7, 2020
It doesn't work for us.
When using
<Switch>, the parent component successfully unmounts, but it also unmounts when it should not (when the path changes but should still keep the parent component mounted), leading to a blank page, without any kind of console error.Staying with
window.location = '...'for now, regarless of how ugly it is.und3f1ned commentedon Apr 7, 2020
Did you try Ionic lifecycle methods?
Especially this one
useIonViewDidLeave(() => { console.log('ionViewDidLeave event fired'); });OoDeLally commentedon Apr 7, 2020
I just did. None of the 4 events in https://ionicframework.com/docs/react/lifecycle was fired.
royvangeel commentedon Apr 14, 2020
I'm also experiencing the same issue, no lifecyle method will be fired. Tried both class and functional component using the ionic docs.
elylucas commentedon Apr 14, 2020
Hello all,
I'm looking into this now, hope to have something to report on soon.
elylucas commentedon Jun 23, 2020
Hi All,
We have a dev release that provides better support for nested IonRouterOutlet components. There is a new prop on IonRouterOutlet that lets the router know it is a nested outlet to better perform the transition.
If your'e outlet is a nested outlet directly rendered by a Route in a parent outlet, then use the
ionPageprop on the IonRouterOutlet. Here is an example:App.tsx:
Sub1Outlet.tsx:
Sub2Outlet.tsx:
If you can, could you try to install it and let us know if it fixes the issue and if you run into any others? To install it run:
npm i @ionic/[email protected] @ionic/[email protected]If all goes good this should be available in the next Ionic release.
Thanks!
mateuskb commentedon Aug 4, 2020
It didn't unmount the component for me. For now I will stick with
routerDirection="back". Although it's not correct, it's working the way I need7 remaining items
basicBrogrammer commentedon Nov 10, 2020
I added routerDirection back to any link going to the given route that i wanted to "remount"
wibed commentedon Dec 8, 2020
what is the state on this issue?
Nested routes result in breaking third party libraries (replacing ionRouterOutlet with Switch works)
anyways navigation is crucial
allanyego commentedon Dec 8, 2020
You have to remember that replacing IonRouterOutlet with a Switch will mean converting all your useIonViewDidEnter with useEffects and lose animations.
emindeniz99 commentedon Jan 7, 2021
Is there any new news?
MiguelHernandezCh commentedon Jan 24, 2021
I found a workaround.
You can set an
idto the<IonPage>. When you click the header button, the app will go back and remove your page from the DOM.This is to force unmount the page, and because this page is no longer on the DOM it cannot execute its life cycles.
This is my helper function
This is my page
This is my custom header
Hope this helps
jamt0 commentedon Feb 24, 2021
This is a huge blocker for me.
ItayElgazar commentedon Sep 19, 2021
Any updates?
ashleydavis commentedon Jan 21, 2022
It seems to me that Ionic just don't deal with these issues.
e-kotsiuk commentedon Aug 16, 2022
In case of Vue framework, adding key attribute to "ion-router-outlet" resolved it for me
<ion-router-outlet id="main-content" :key="route.fullPath" ></ion-router-outlet>Mati-Educa commentedon Mar 27, 2023
I found a workaround. I'm just using the React router feature to go to another page.
That code triggers an unmounted event.
I hope this workaround is helpful to you.
jeffvandyke commentedon Mar 2, 2024
Stumbled across this issue today, found that links and ion items accept a
routerOptionsproperty withunmount: truethat seems to take care of it.ionitron-bot commentedon Mar 2, 2025
Thanks for the issue! This issue is being closed due to inactivity. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out.
Thank you for using Ionic!