mercredi 4 août 2021

React only display components of array properties that exist

I want to only display the following components if their href property exists:

 <ExternalLinks href={source}>Code</ExternalLinks>
 <ExternalLinks href={download}>Download</ExternalLinks>
 <ExternalLinks href={visit}>Website</ExternalLinks>

Here is the array, for example if the download and visit properties don't exist for the array object then I don't want them to appear.

    title: 'Ethereum Kickstarter Project',
    description: "Using React, Node.js, Solidity, I built an Ethereum decentralised crowd-funding alternative to GoFundMe. ",
    image: '/images/ethereumcampaign.png',
    tags: ['React', 'Node.js', 'Solidity'],
    href: "/campaigns",
    //download: 'https://google.com',
    source: 'https://github.com/rlm42/kickstart',
    //visit: "",
    id: 0,

Thanks :)




Aucun commentaire:

Enregistrer un commentaire