I tried many methods to display dynamically Icons,but this one work in my case:
<div style={{display: "flex", flexDirection: "row"}}>
{logo?.map((logos, index )=> {return (
<React.Fragment key={index}>
<IconContext.Provider
key={index}
value={{ color: "#fff", size: '30px', display: "inlineblock"}}
>
<div>
{logos}
</div>
</IconContext.Provider>
</React.Fragment>
)}) }</div>
I have this (in future I want it fetch from database) in const:
const realizacjeGallery = [{
id: "ssss",
title: "ssss",
description: <>zzxxx</>,
photo: zzz,
logo: [<DiReact/>, <SiFirebase/>]
},
{ id: "ss",
title: "ssss",
description: <>zzz
</>,
photo: zzz,
logo: [<DiReact/>, <SiFirebase/>]
},
{
id: "zzz",
title: "sssl",
description: <>ssss
</>,
photo: muz,
logo: [<BsWordpress/>, <DiJqueryLogo/>]
}
]
and this piece of code display on frond-end my icons. But after deployment, I get an fatal error:
Error: Missing "key" prop for element in array react/jsx-key
and I do not have any clue what more I should do. I tried many combinations of key like key={`${title}` + index}
but it do not change anything.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.