0

I am creating SPFx web-part in which I am using office fabric to bind SharePoint image link (hyperlink column).

Web-part works fine if all values present. If hyperlink column is blank web-part does not load at all.

it throw error:

Uncaught TypeError: Cannot read property 'Url' of null

<div >
    {
        this.state.items.map((items,key)=>{    
            return(
                <DocumentCard styles={cardStyles} onClick={() =>
                    this.Showitem(items.Template)}>
                    <DocumentCardImage height={150} imageFit={ImageFit.cover} imageSrc={items.ImageLink["Url"]} />
                    <DocumentCardDetails>
                        DocumentCardTitle title={items.GPDTemplate} />
                    </DocumentCardDetails>
                </DocumentCard>
            );
    })}
</div>
2

Try using below line in your code:

<DocumentCardImage height={150} imageFit={ImageFit.cover} imageSrc={items.ImageLink ? items.ImageLink["Url"] : ''} />
  • Thank you its working – kumar Sep 6 at 4:15
  • 1
    welcome. Glad it worked for you. – Ganesh Sanap Sep 6 at 4:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.