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 +