Showing a message when there are no songs or no artists

You could also use conditional rendering in the SongsList and ArtistsList components to display a message when there are no elements to display.

Here's how we've done this for songs in the final version of the code:

<Container className='lf-songs'> 
    {songElements.length > 0? ( 
    <ListGroup> 
        {songElements} 
    </ListGroup> 
    ) : ( 
       <span>No songs</span> 
    )} 
</Container> 

This approach uses a ternary operator to either render the ListGroup element or span. There are many other ways to do conditional rendering with React; check out the following references for more details:

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.141.8.247