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

357
Views
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 answers
Answer question

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 Report

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 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!