Skip to content

bug: IonTabs needs a IonTabBar #21541

Description

@TylerBurnett

Bug Report

Ionic version:

[ ] 4.x
[x] 5.x React

Current behavior:
Conditionally rendering IonTabBar throws error.

Expected behavior:
As commented in the error caller, the error is unnecessary and should be removed.

Location: /IonTabs.tsx:100
if (!tabBar) {
   // TODO, this is not required
 throw new Error('IonTabs needs a IonTabBar');
}

Steps to reproduce:

  1. Create a project with IonTabs and React,
  2. Comment out the IonTabBar.

Related code:
Example conditional renderer:

const showTabNav = false;

...
<IonTabs>
 <IonRouterOutlet>
...
</IonRouterOutlet>
 {showTabNav && (
            <IonTabBar slot="bottom">
              <IonTabButton tab="tab1" href="/tab1">
                <IonIcon icon={mapOutline} />
                <IonLabel>Explore</IonLabel>
              </IonTabButton>
              <IonTabButton tab="tab2" href="/tab2">
                <IonIcon icon={homeOutline} />
                <IonLabel>Deals</IonLabel>
              </IonTabButton>
              <IonTabButton tab="tab3" href="/tab3">
                <IonIcon icon={walletOutline} />
                <IonLabel>Wallet</IonLabel>
              </IonTabButton>
            </IonTabBar>
          )}
</IonTabs>

Other information:
N/A

Ionic info:
N/A

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions