Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

237
Views
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 answers
Answer question

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 Report

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!