From 355feddef7b85a5739e05907e549c87fbe5bf9ee Mon Sep 17 00:00:00 2001 From: Liam DeBeasi Date: Thu, 29 Jun 2023 09:47:39 -0400 Subject: [PATCH] docs(react): clarify IonTabs behavior with IonPage As noted in https://github.com/ionic-team/ionic-framework/issues/27705, it turns out that IonTabs in Ionic React automatically renders IonPage for you, so adding duplicate IonPage instances can cause issues. This behavior is not aligned with Vue, so we should look into making this consistent in the future. For now, I've updated the docs to make this clear. --- docs/react/navigation.md | 70 +++++++++++++++++++++------------------- 1 file changed, 36 insertions(+), 34 deletions(-) diff --git a/docs/react/navigation.md b/docs/react/navigation.md index e54acf220db..d85676786cc 100644 --- a/docs/react/navigation.md +++ b/docs/react/navigation.md @@ -419,7 +419,7 @@ Let's start by taking a look at our `Tabs` component: ```tsx import { Redirect, Route } from 'react-router-dom'; -import { IonPage, IonIcon, IonLabel, IonRouterOutlet, IonTabBar, IonTabButton, IonTabs } from '@ionic/react'; +import { IonIcon, IonLabel, IonRouterOutlet, IonTabBar, IonTabButton, IonTabs } from '@ionic/react'; import { IonReactRouter } from '@ionic/react-router'; import { ellipse, square, triangle } from 'ionicons/icons'; import Tab1 from './pages/Tab1'; @@ -427,39 +427,37 @@ import Tab2 from './pages/Tab2'; import Tab3 from './pages/Tab3'; const Tabs: React.FC = () => ( - - - - - - - - - - - - - - - - - - - - - Tab 1 - - - - Tab 2 - - - - Tab 3 - - - - + + + + + + + + + + + + + + + + + + + + Tab 1 + + + + Tab 2 + + + + Tab 3 + + + ); export default Tabs; @@ -467,6 +465,10 @@ export default Tabs; If you have worked with Ionic Framework before, this should feel familiar. We create an `IonTabs` component and provide an `IonTabBar`. The `IonTabBar` provides `IonTabButton` components, each with a `tab` property that is associated with its corresponding tab in the router config. We also provide an `IonRouterOutlet` to give `IonTabs` an outlet to render the different tab views in. +:::tip +`IonTabs` renders an `IonPage` for you, so you do not need to add `IonPage` manually here. +::: + ### How Tabs in Ionic Work Each tab in Ionic is treated as an individual navigation stack. This means if you have three tabs in your application, each tab has its own navigation stack. Within each stack you can navigate forwards (push a view) and backwards (pop a view).