Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

251
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda