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>

1 Answer 1

2

Try using below line in your code:

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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