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

365
Views
El componente React dentro de .map() arroja un error: TypeError: notes.map no es una función

Estoy tratando de mostrar el componente Noteitem que se devuelve dentro de una función de mapa.

 {notes.map((note) => { return ( <Noteitem key={note._id} updateNote={updateNote} showAlert={props.showAlert} note={note} /> ); })}
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

las notes deben ser una matriz para que funcione la función de map . Puede verificarlo de la siguiente manera si las notes no son null y son una matriz usando notes.length y aplicar la función de map

 {notes && notes.length && notes.map((note) => { return ( <Noteitem key={note._id} updateNote={updateNote} showAlert={props.showAlert} note={note} /> ); })}
about 4 years ago · Juan Pablo Isaza Report

0

Puede poner la declaración if/else dentro de JSX para verificar si la variable existe o no

 return ( <> { notes.length ? 'fallback' : notes.map(note => <Noteitem key={note._id} updateNote={updateNote} showAlert={props.showAlert} note={note} />) } </> )

IIFE

 {(() => { if ("check note") { // fallback } return notes.map((note: NoteProps) => ( <Noteitem key={note._id} updateNote={updateNote} showAlert={props.showAlert} note={note} /> )); })()}
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!