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

252
Views
How to solve infinite loop in JSX?

Im trying to map my userForm state to render each by each , but the map function sometimes returns me as undefiend and sometimes as an react infinite loop and I'm not finding a way to solve it, somene could help me ?

my code:

const FormScreen = async({route}) => { 
  const [userForm, setuserForm] = useState([]);

  if (userForm.length > 0) {
    console.log(userForm,'campos:',userForm.fields);
    return;
  } else {
    setuserForm(await JSON.parse(route.params.paramKey));
  }
         {...}

return (
    <SafeAreaView style={{flex: 1}}>
      <View style={styles.container}>
        <Text style={styles.textStyle}>
          COLLECTION :
        </Text>

      {userForm.map((item) => (             
      <Text keys={item.fields}>test</Text>        
      ))} 
       
      </View>

    </SafeAreaView>
  );
 };
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Move setuserForm(await JSON.parse(route.params.paramKey)); into a useEffect hook.

https://reactjs.org/docs/hooks-effect.html

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!