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

197
Views
How to apply conditionals in a nested map function?

I want to handle each string of my item.fieldtype result, but i'm not finding a way to do it someone knows how?

....
      <SafeAreaView style={{flex: 1}}>
          <View>
            {Object.keys(Body).length > 0 ? (
              Body.map(item => <Text key={uuid.v4()}>{item.field}</Text>
              // if (item.fieldtype == "Numeric") <Text>Numeric</text> ===> apply here
              //else if (item.fieldtype == "Text" ) <Text>Text</text> ===> "" ""      
              )
            ) : (
              <Text>Testado</Text>
            )}
          </View>
        </SafeAreaView>
...
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You can use a fragment tag (or just a View) and return multiple items in the map:

<SafeAreaView style={{flex: 1}}>
  <View>
    {Object.keys(Body).length > 0 ? 
      (Body.map(item => 
       <React.Fragment key={uuid.v4()}>
          <Text>{item.field}</Text>
          {item.fieldtype == "Numeric" ? <Text>Numeric</Text> : null}
          {item.fieldtype == "Text" ? <Text>Text</Text> : null}
       </React.Fragment>))
      : (<Text>Testado</Text>)}
  </View>
</SafeAreaView>

(Note that it would be ideal if you had useable stable ids rather than generating a new uuid for each item on each render)

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!