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

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

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 Report

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