In my React and TypeScript (version "^3.9.9"
) app I am mapping over some items to render the list/teasers:
{data?.getItems.items
.map((teaser) => (
<Teaser
key={teaser.id}
title={teaser.extraData?.title || video.title}
label={teaser.extraData?.label}
/>
))}
extraData
object can be null queried with Graphql from api. I am using Typescripts Optional chaining.
It's enough to prevent my app from breaking to add teaser.extraData?.title
.
But what is the difference between teaser?.extraData?.title
and teaser.extraData?.title
and what should I use to be safe?