how to use this map function in React to call url with images name

  socialLinks: {
    instagram: '',
    facebook: '',
    linkedin: '#',

how to create a loop so that result should come like this –

   <a href="">
      <image src="instagram.png" />
   <a href="">
      <image src="facebook.png" />

Note: If there is no link of linkedin then no link and image will come

>Solution :

You can take advantage of Object.entries:

        Object.entries(socialLinks).filter(([k,v]) => v.startsWith("https:")).map(([k,v]) => 
            <a key={v} href={v}>
                <image src={`${k}.png`} />

Leave a Reply