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

254
Vistas
I want to show and hide a element (ActivityIndicator)

What I'm trying to do is when I click the button it disappears, and when it's already loaded in another component it shows again the button.

JSX code:

import { ActivityIndicator } from 'react-native';
     {......}
    {/button besides loading/}
                    <LinearGradient
                        colors={['#D97B29', '#F2B47E']}
                        style={styles.signIn}
                    >
                        <Text style={[styles.textSign, {
                            color:'#fff'
                        }]}>Entrar</Text>
                        {/loading besides button /}
                        <ActivityIndicator size="large" color="#D97B29" />
                    </LinearGradient>
                      {...}

How can I handle it whit the useState?

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

Assuming you want to hide/show the indicator when the button is pressed, you need

const [ showLoader, setShowLoader ] = useState(false);

Your button on press should show something like

<Button onPress={() => setShowLoader(!showLoader)} text="Some text" />

and your code should look like

              {showLoader && (
                <ActivityIndicator size="large" color="#D97B29" />             
              )}
              {!showLoader && <LinearGradient
                        colors={['#D97B29', '#F2B47E']}
                        style={styles.signIn}
                    >
                        <Text style={[styles.textSign, {
                            color:'#fff'
                        }]}>Entrar</Text>
                    </LinearGradient> }
    ```
about 4 years ago · Juan Pablo Isaza Denunciar

0

something like this

{state && <ActivityIndicator size="large" color="#D97B29" />}

if state is true it will show the component

about 4 years ago · Juan Pablo Isaza Denunciar
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