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

193
Views
¿Cómo resolver undefined no es una función (cerca de '... userForm.map...')?

Estoy tratando de renderizar algunas cadenas, pero recibo un error, ¿alguien sabe cómo resolverlo?

código:

 const FormScreen = ({route}) => { const [userForm, setuserForm] = useState([]); useEffect(() => { if (userForm.length > 0) { console.log('userform',userForm,userForm.length); // not get inside here gives me a eror before it return } else{ setuserForm(route.params.paramKey); console.log('TEST',userForm,'LENG',userForm.length)} // returns => TEST [] LENG 0 },[userForm]) return ( <SafeAreaView style={{flex: 1}}> <View style={styles.container}> <Text style={styles.textStyle}>COLLECTION :</Text> {userForm.length > 0 ? ( userForm.map((item) => ( <Text key={uuid.v4()}>{item.fields}</Text> )) ) : ( <Text key={uuid.v4()}> Loading ... </Text> )} {..}

route.params.paramKey es una cadena

route.params.paramKey cadena es = {"objeto":"CLMobj_test","fields":["abcs","test"],"type":["Date","Text"]}

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

0

Dado que route.params.paramKey es una cadena, no puede llamar al map directamente. Si desea seguir adelante con este enfoque, puede hacer algo como esto:

 setuserForm([...route.params.paramKey]);

EDITAR: después de agregar

 route.params.paramKey = {"objeto":"CLMobj_test","fields":["abcs","test"],"type":["Date","Text"]}

solo puedes configurar

 setuserForm(JSON.parse(route.params.paramKey).fields)

y usa el mapa en él

 {userForm.length > 0 ? (userForm.map((item) => <Text key={uuid.v4()}>{item}</Text>): (<Text key={uuid.v4()}> Loading ... </Text>) }
about 4 years ago · Juan Pablo Isaza Report

0

¿Puedes probar con este código? Ten en cuenta que he cambiado la condición "Usar efecto", y JSX también:

 const FormScreen = ({route}) => { const [userForm, setuserForm] = useState([]); useEffect(() => { setuserForm(JSON.parse(route.params.paramKey)); },[]) return ( <SafeAreaView style={{flex: 1}}> <View style={styles.container}> <Text style={styles.textStyle}>COLLECTION :</Text> {!!userForm && userForm.fields.length > 0 ? ( userForm.fields.map((item) => ( <Text key={uuid.v4()}>{item}</Text> )) ) : ( <Text key={uuid.v4()}> Loading ... </Text> )}
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!