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 >
                <DocumentCard styles={cardStyles} onClick={() =>
                    <DocumentCardImage height={150} imageFit={ImageFit.cover} imageSrc={items.ImageLink["Url"]} />
                        DocumentCardTitle title={items.GPDTemplate} />

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 '19 at 4:15
  • 1
    welcome. Glad it worked for you. – Ganesh Sanap Sep 6 '19 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.