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

165
Vistas
Getting Undefined while accessing the values of data object inside map in Next.js

// while accessing the object values from data, I'm getting undefined in map

// ../data/section1

const data = [{
    id: 1,
    image: './images/homepage/xbox-games.png',
    text: 'Buy Xbox games and consoles',
}, {
    id: 2,
    image: './images/homepage/shop_surface_devices.webp',
    text: 'Shop surface devices',
}, {
    id: 3,
    image: './images/homepage/choose_your_ms_365.png',
    text: 'Choose your Microsoft 365',
}, {
    id: 4,
    image: './images/homepage/shop_windows_10.png',
    text: 'Shop Windows 10',
}]
export default data;

// the actual component

    import data from "../data/section1";
    
    const Section1 = () => {
    
      return (
        <>
            <div class="mx-20">
                {data.map((vals) => {
                  <div class="">
                    <img src={vals.image}/>
                    <p>{vals.text}</p>
                  </div>
                })}
            </div>
        </>
      )
    }
    
    export default Section1;
about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

return JSX from the map

    import data from "../data/section1";
    
    const Section1 = () => {
    
    
      return (
        <>
            <div class="mx-20">
                {data.map((vals) => {
                  return (
                    <div class="">
                      <img src={vals.image}/>
                      <p>{vals.text}</p>
                    </div> 
                  )
                })}
            </div>
        </>
      )
    }
    
    export default Section1;
about 4 years ago · Juan Pablo Isaza Denunciar

0

I had the same problem, then tried the first bracket instead of the second, and it resolved the problem

import data from "../data/section1";

const Section1 = () => {

  return (
    <>
        <div class="mx-20">
            {data.map((vals) => (
              <div class="">
                <img src={vals.image}/>
                <p>{vals.text}</p>
              </div>
            ))}
        </div>
    </>
  )
}

export default Section1;
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