Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

170
Vistas
How to display another icon when tab is active in Ionic React?

I have this tab-bar where active elements have another icon than inactive:

enter image description here

It will also change the item with the onIonTabsDidChange-hook from IonTabBar:

const [activeTab, setActiveTab] = useState<string>()

return 
<IonTabBar onIonTabsDidChange={(event) => setActiveTab(event.detail.tab)}>
  <IonTabButton  tab="explore" href="/explore">
    {activeTab === 'explore' ? <HomeIconSolid /> : <HomeIcon />}
  </IonTabButton>
  <IonTabButton tab="game" href="/game" >
    {activeTab === 'game' ? <PlayIconSolid/> : <PlayIcon />}
  </IonTabButton>
</IonTabBar>

My problem is that when the page is loaded first time (without any change Tab events) it will not display the correct item:

enter image description here

How can I achieve to set the icon at first load as well?

  • I'm not able to define a default! Because users could enter the page from a different url (e.g.: game is the first page)
  • I searched for an init / load hook but didn't find one
about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda