I have a graphql request. It works fine, but if the poster is missing I got errors. I tried to fix like this:
<div className="movie__hero">
<img
src={ movie.poster.large == null ? "poster" : movie.poster.large }
alt="Poster"
className="movie__img"
/>
</div>
Any ideas to fix the issue?
CodePudding user response:
The error isn't telling you that large
is null
, it's telling you that poster
is null
:
src={ movie.poster == null ? "poster" : movie.poster.large }
CodePudding user response:
Based on your error, you need to check if movie.poster
is null or not.
src={ movie.poster == null ? "poster" : movie.poster.large }