Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

358
Vistas
React Component inside .map() is throwing an error: TypeError: notes.map is not a function

am trying to show Noteitem component which is returned inside a map function.

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

0

notes should be an array for map function to work. You can check it in following way if notes is not null and is an array using notes.length and apply map function

{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 Denunciar

0

You can put if/else statement inside JSX to check the variable whether is exist or not

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda