Recibo TypeError: no puedo leer las propiedades de undefined (leyendo '0') cuando intento acceder a los datos que extraje de mi base de datos (receivedData, que es un objeto). console.log mis datos receivedData y tiene datos. Así es como se ve mi estructura social donde está una de las claves de mi 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> }No hay ningún campo de item en logoObj . Debe acceder a la clave dinámicamente con 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> }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> )}