React + Ionic 5: Tab Navigation Problems

I'm having trouble to get tabs navigation working properly.

This is my code so far:


const App: React.FC = () =>
          <IonRouterOutlet id="main">
              <Route exact path="/" render={() => <Redirect to="/home"/>}/>
              <Route path="/home" render={(props) => <Home {...props}/>} exact={true}/>


const Home: React.FC<RouteComponentProps> = (props: RouteComponentProps) => (
            <IonRouterOutlet id='tabs'>
                <Route path='/:tab(myDecks)' render={(props) => <MyDecks {...props} />} exact/>
                <Route path='/:tab(explore)' render={(props) => <Explore {...props} />} exact/>
                <Redirect from='/home' to='/myDecks'/>
            <IonTabBar slot='bottom'>
                <IonTabButton tab='myDecks' href='/myDecks'>
                    <IonLabel>My Decks</IonLabel>
                <IonTabButton tab='explore' href='/explore'>


const MyDecks: React.FunctionComponent<RouteComponentProps> = (props: RouteComponentProps) => {
    return <>
                    <IonTitle>My Decks</IonTitle>

            <IonContent className='ion-padding'>
                My Decks

The current behavior is:

  1. User access /
  2. User is redirected to /home
  3. Another redirect to /myDeck, "My Deck" tab selected and URL is good.
  4. If the user clicks on the "Explore" tab, URL changes, "My Deck" tab is deselected and the "Explore" tab is selected, however, the page content doesn't change.

If I alter the order of the routes inside <IonRouterOutlet>, then the "My Decks" tab is originally selected, and when the user first clicks the "Explore" tab, it renders ok, but never get back to "My Decks" tab.

I also noticed that when refreshing at /myDeck or /explore no content renders at all.



According to the React Tabs starter template you have to nest the IonRouterOutlet inside of IonTabs, which is nested in IonReactRouter.

Here's how their App.tsx looks like:

          <Route path="/tab1" component={Tab1} exact={true} />
          <Route path="/tab2" component={Tab2} exact={true} />
          <Route path="/tab3" component={Tab3} />
          <Route path="/" render={() => <Redirect to="/tab1" />} exact={true} />
        <IonTabBar slot="bottom">
          <IonTabButton tab="tab1" target="_blank" rel="nofollow noreferrer" href="/tab1">
            <IonIcon icon={triangle} />
            <IonLabel>Tab 1</IonLabel>
          <IonTabButton tab="tab2" target="_blank" rel="nofollow noreferrer" href="/tab2">
            <IonIcon icon={ellipse} />
            <IonLabel>Tab 2</IonLabel>
          <IonTabButton tab="tab3" target="_blank" rel="nofollow noreferrer" href="/tab3">
            <IonIcon icon={square} />
            <IonLabel>Tab 3</IonLabel>

For me it worked that way. Anyway Ionic+React documentation is not very detailed regarding things like that. One still has to search very much.