Ionic 6 with React - no animation on page navigation
Asked Answered
P

2

6

I'm building an Ionic React (using Ionic 6 and Capacitor) application. I have two pages, Home and Profile. I want to navigate between the home page and profile page, it is working but there is no push animation on the iOS simulator.

This is my Router (on App.tsx):

 <IonApp>
     <IonRouterOutlet>
      <IonReactRouter>
        <Route exact path="/home" component={Home} />
        <Route exact path="/profile" component={Profile} />
        <Route exact path="/" render={() => <Redirect to="/home" />} />
      </IonReactRouter>
    </IonRouterOutlet>
 </IonApp >

Home and Profile of course have IonPage as the root element.

return (
        <IonPage>
            ...
            ...
       </IonPage>
);

I use useIonRouter hook, like this:

 const router = useIonRouter();
 const displayProfile = () => {
    router.push('/profile', 'forward', 'push');
};

It does go to the Profile page, but with no animation at all. I couldn't find anything but basic examples on their website for the this.

Purlieu answered 12/2, 2022 at 17:40 Comment(6)
maybe this will help #58452659Pyramidal
@Pyramidal Thank you, I read this before posting, and it does actually work, but as I said, I don't see the animation being played.Purlieu
Do you have a IonRouterOutlet in the Home and Profile pages?Hemocyte
@Hemocyte No, I copied the docs and I didn't see where they added it. I do have the RouterOutlet on the App.tsxPurlieu
It's strange that not even the code examples from the docs work...Hemocyte
Have you found a solution ? I struggle with the same issue...Phaedrus
F
0

the page you are going to should contain IonContent inside IonPage

Flourishing answered 7/10 at 7:55 Comment(0)
L
-1

Per the official example, be sure to include the CSS

/* Core CSS required for Ionic components to work properly */
import '@ionic/react/css/core.css';

/* Basic CSS for apps built with Ionic */
import '@ionic/react/css/normalize.css';
import '@ionic/react/css/structure.css';
import '@ionic/react/css/typography.css';
Lindquist answered 22/2, 2022 at 18:33 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.