From f50a938b0448aaab43839d0b5f0eeb0e5d5917d2 Mon Sep 17 00:00:00 2001 From: Maria Hutt Date: Thu, 3 Dec 2026 16:02:42 -0800 Subject: [PATCH] docs(tabs): select tabs from IonTabsContext in the React example --- .../v9/tabs/select-method/react/main_tsx.md | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/static/usage/v9/tabs/select-method/react/main_tsx.md b/static/usage/v9/tabs/select-method/react/main_tsx.md index 02b6b7d41a3..bf5601611a2 100644 --- a/static/usage/v9/tabs/select-method/react/main_tsx.md +++ b/static/usage/v9/tabs/select-method/react/main_tsx.md @@ -1,5 +1,5 @@ ```tsx -import React, { useRef } from 'react'; +import React, { useContext } from 'react'; import { IonButton, IonContent, @@ -7,6 +7,7 @@ import { IonHeader, IonTab, IonTabs, + IonTabsContext, IonTabBar, IonTabButton, IonTitle, @@ -18,12 +19,13 @@ import { playCircle, radio, library, search } from 'ionicons/icons'; import './main.css'; -function Example() { - const selectRadio = () => { - const tabs = document.querySelector('ion-tabs'); - tabs?.select('radio'); - }; +function GoToRadioButton() { + const { selectTab } = useContext(IonTabsContext); + + return selectTab('radio')}>Go to Radio; +} +function Example() { return ( @@ -36,7 +38,7 @@ function Example() {
Listen now content - Go to Radio +