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

204
Vistas
TypeError: Cannot read properties of undefined (reading '0') whilte trying to accessing an array of object data

I am getting TypeError: Cannot read properties of undefined (reading '0') when I'm trying to access the data that I've pulled from my database (receivedData which is an object). I've tried console.log my receivedData and it does have data in it. Here's how my social structure looks like where it is one of the keys of my receivedData object.

const logoObj = {
    "telegram": telegramWIcon,
    "twitter": twitterWIcon,
    "website": linkWIcon,
    "whitepaper": fileWIcon
  }

{receivedData.social[0] !== null &&
   <div>
       { Object.entries(receivedData.social[0]).forEach((item) =>
           item[1] !== null ? <SocialMedia url={logoObj.item[0]} link={item[1]} /> : ""
       )}
   </div>
}
about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

There is no item field in logoObj. You need to access the key dynamically with logoObj[item].

const logoObj = {
    "telegram": telegramWIcon,
    "twitter": twitterWIcon,
    "website": linkWIcon,
    "whitepaper": fileWIcon
  }

{receivedData.social[0] !== null &&
   <div>
       { Object.entries(receivedData.social[0]).forEach((item) =>
           item[1] !== null ? <SocialMedia url={logoObj[item][0]} link={item[1]} /> : ""
       )}
   </div>
}

about 4 years ago · Juan Pablo Isaza Denunciar

0

const logoObj = {
  telegram: telegramWIcon,
  twitter: twitterWIcon,
  website: linkWIcon,
  whitepaper: fileWIcon,
};

{receivedData.social[0] !== null && (
  <div>
    {Object.entries(receivedData.social[0]).map(([type, link]) => {
      if (!link || !logoObj[type]) {
        returt null;
      }

      return <SocialMedia key={link} link={link} url={type} />;
    })}
  </div>
)}
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