Skip to content

bug: IonTabs needs a IonTabBar #21541

@TylerBurnett

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="https://github.com/tab1">
                <IonIcon icon={mapOutline} />
                <IonLabel>Explore</IonLabel>
              </IonTabButton>
              <IonTabButton tab="tab2" href="https://github.com/tab2">
                <IonIcon icon={homeOutline} />
                <IonLabel>Deals</IonLabel>
              </IonTabButton>
              <IonTabButton tab="tab3" href="https://github.com/tab3">
                <IonIcon icon={walletOutline} />
                <IonLabel>Wallet</IonLabel>
              </IonTabButton>
            </IonTabBar>
          )}
</IonTabs>

Other information:
N/A

Ionic info:
N/A

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