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

260
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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