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

281
Views
Is there a way to use a map inside of another map function?

What I'm trying to do is after a field name, I want to render its type which is in another state as you can see:

my code:

    const FormScreen = ({route}) => {
      const [FieldForm, setFieldForm] = useState([]);
      const [TypeForm, setTypeForm] = useState([]);
    
    useEffect(() => {
      if (userForm.length > 0) {
        return;
      } else {
        setFieldForm(JSON.parse(route.params.paramKey).fields);
        setTypeForm(JSON.parse(route.params.paramKey).type);
        console.log(FieldForm,TypeForm);  // returns me: {"message":["ab","test"],"tipo":["Date","Text"]}
      }
    },[userForm,TypeForm]);   
    return (
      <SafeAreaView style={{flex: 1}}>
        <View>
          <Text>COLLECTION :</Text>
    
          {FieldForm.length > 0 ? (
            FieldForm.map((item) => (          
              <Text key={uuid.v4()}>{item}</Text>
              //Here I want to to map which type is the field(to use conditionals to render) but how can I make it? 
            ))
          ) : (
            <Text key={uuid.v4()}> Loading ...</Text>
          )}
    
        </View>
      </SafeAreaView>
    );
    };

How can I use a map inside of a map to do it, or creating an api call to return the type of the fields?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You can definitely nest the map functions :

const FormScreen = ({route}) => {
      const [FieldForm, setFieldForm] = useState([]);
      const [TypeForm, setTypeForm] = useState([]);
    
    useEffect(() => {
      if (userForm.length > 0) {
        return;
      } else {
        setFieldForm(JSON.parse(route.params.paramKey).fields);
        setTypeForm(JSON.parse(route.params.paramKey).type);
        console.log(FieldForm,TypeForm);  // returns me: {"message":["ab","test"],"tipo":["Date","Text"]}
      }
    },[userForm,TypeForm]);   
    return (
      <SafeAreaView style={{flex: 1}}>
        <View>
          <Text>COLLECTION :</Text>
    
          {FieldForm.length > 0 ? (
            FieldForm.map((item) => (
              <>          
                <Text key={uuid.v4()}>{item}</Text>
                <> {TypeForm.length && TypeForm.map((type) => ( // Return node )) || null};
                </>
              </>
            ))
          ) : (
            <Text key={uuid.v4()}> Loading ...</Text>
          )}
    
        </View>
      </SafeAreaView>
    );
    };
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!