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

227
Views
La matriz multidimensional devuelve No se pueden leer las propiedades de undefined (leyendo 'mapa')

Cuando estoy trabajando en localhost o incluso con la compilación, todo funciona perfectamente, pero cuando se implementa el sitio, aparece este error: No se pueden leer las propiedades de undefined (leyendo 'mapa') . No entiendo porque. El sitio está desarrollado con React y Redux .

 {questionsAndAnswers.map((q, index) => <div key={q.id} className={"votre-question-card"} onClick={() => history.push(`/question/${q.id}`)}> <h3>Votre question {index + 1}</h3> <p>{dayjs(q.date).format("DD/MM/YYYY")}</p> {q.reponses.map((r)=> { if (r.state == 0) return <p className={"votre-question-card-message"}>1 nouveau message</p>; else return null; } )} </div> )}

Cuando lo depuro, el primer bucle del segundo mapa {q.reponses.map((r, index) => funciona, pero el segundo bucle crea el error Cannot read properties of undefined (reading 'map')

Preguntas y respuestas devuelve una matriz multidimensional (que contiene objetos y una matriz: reponses , lo que estoy tratando de devolver)

 Array (5) 0 Object content: "" date: "2022-02-17 14:41:29" dateClosed: "0000-00-00 00:00:00" id: "10" idUser: "3499" listReponses: [] (0) reponses: Array (2) 0 {id: "16", idQuestion: "10", idCareManager: "0", date: "2022-02-18 12:10:50", state: "1", …} 1 {id: "6", idQuestion: "10", idCareManager: "2", date: "2021-12-01 11:44:10", state: "1", …} 1 {id: "11", idUser: "3499", date: "2022-02-21 10:54:06", dateClosed: "0000-00-00 00:00:00", state: "0", …} 2 {id: "12", idUser: "3499", date: "2022-02-23 16:07:37", dateClosed: "0000-00-00 00:00:00", state: "0", …} 3 {id: "13", idUser: "3499", date: "2022-02-23 16:44:48", dateClosed: "0000-00-00 00:00:00", state: "0", …}

El misterio para mí es que funciona en localhost y en la compilación, pero no en producción , con el mismo navegador. Puede alguien ayudarme ??

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

0

El error anterior está ocurriendo en q.reponses.map. Para resolver esto, debe agregar el siguiente código:

 {q.reponses && q.reponses.map((r) => { if (r.state == 0) return ( <p className={'votre-question-card-message'}> 1 nouveau message </p> ); else return null; })}
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!