Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ionic router creates ionic-page-invisible and not removed

ion-router-outlet creates an ion-page-invisible class on the routed component. It doesn't remove it on first load, as a result shows a white screen. Subsequent visits are fine, or a reload will remove it. I tried manually remove the class as I found on the internet, but it doesn't work. This page-invisible is blocking the entire content. You can see the components inside the route on inspection, you can even click on it and it works accordingly but cannot see anything. I've tried rerouting to different components, it is the same. This happens on iOS/safari, mobile and desktop.

I also tried this using regular angular <router-outlet> and that works as expected but I cannot use that here for subsequent components.

My layout:

<ion-app>
        <ion-content class="ion-padding" [scrollEvents]="true" overflow-scroll="false">
            <app-navbar></app-navbar>
            <ion-router-outlet id="main-content"></ion-router-outlet>
        </ion-content>
</ion-app>

Output:

    <ion-router-outlet class="menu-content menu-content-overlay hydrated">
// ion-page-invisible is blocking the view
        <app-component class="ion-page ion-page-invisible">
//shows all the markups in component
</app-component>
    </ion-router-outlet>
like image 871
hammies Avatar asked Oct 24 '25 03:10

hammies


2 Answers

One of the reasons I found out this may happen is when you have more than one ion-page nested. e.g.

<ion-page> // <-- one here
  <ion-router-outlet>
    <route path="/">
      <ion-page> // <-- another one here
        <ion-page> // <-- another one here - This one must be removed!
          ...
        </ion-page>
      </ion-page>
    </route>
  </ion-router-outlet>
</ion-page>

Disclaimers: I am using with React. My module version package.json is as follows:

  • "@ionic/core": "^6.1.5"
  • "@ionic/react": "^6.1.5",
  • "@ionic/react-router": "^6.1.5"

Something to do with the 'stack navigation' not working properly, in my case (https://ionicframework.com/docs/react/navigation#ionpage).

like image 97
Hyfy Avatar answered Oct 25 '25 16:10

Hyfy


I had a similar problem using Angular 17.1.0 and Ionic 8; the problem was apparently in the build – the styles were not being compiled correctly. What worked was disabling build optimization by setting "optimization": false in the Angular.json build options.

like image 23
Hil Zapf Avatar answered Oct 25 '25 18:10

Hil Zapf



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!