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

257
Views
Map function will not render in nextJS

I am trying to get familiar with NextJS so I am building a simple blog. The data is passed thru props and can be console logged inside of the map function, but for some reason will not display any HTML in a browser. no errors to be shown. Prettier in VScode also had to be turned off bc it was adding ";" every time I would save this map function

 <div>
        {post.map((post) => {
          {console.log(post.description + "here")}
          <h1>post</h1>
          
        })}
 </div>

console log will show up in the console but the h1 does render to screen.

Does anybody have some advice?

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

0

Firstly, you need to check post.map((post) => (...). They're having the same variable post from inner to outer. It should be posts.map((post) => (...)) (with posts for the loop)

map function also expects a return value, but you haven't returned any value

 <div>
        {posts.map((post) => {
          return <h1>post</h1>
        })}
 </div>

The shorter version (without brackets)

 <div>
   {posts.map((post) => <h1>post</h1>)}
 </div>

I'd suggest you have key in map results too that would help React recognize your unique elements in posts for re-rendering

 <div>
   {posts.map((post) => <h1 key={post.id}>post</h1>)} //`post.id` is a unique value
 </div>
about 4 years ago · Juan Pablo Isaza Report

0

 <div>
        {post.map((post) => (
          {console.log(post.description + "here")}
          <h1>post</h1>
          
        ))}
 </div>

The map function was not not returning anything . so added the parenthesis or you can use return() and paste the console section

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!