Accepted answer

If the cover needs to be retrieved, put it into state:

const Album = (props) => {
    const [cover, setCover] = useState('');

Get the cover, if needed, when the component mounts:

useEffect(() => {
    if (!props.album.thumbnail) {
}, []);
// inside getAlbumCover:
.then(res => res.json())
.catch(handleError); // don't forget this; unhandled rejections should always be avoided

Then render it:

<img id={`img-${}`} src={album.thumbnail || cover} />

Related Query

More Query from same tag