score:1

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) {
        getAlbumCover();
    }
}, []);
// inside getAlbumCover:
.then(res => res.json())
.then(setCover)
.catch(handleError); // don't forget this; unhandled rejections should always be avoided

Then render it:

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

Related Query

More Query from same tag