Optional: map() + key attribute
A good rule of thumb as to when to use the key attribute you saw in the previous video, is this: Anytime you use the map()
function inside of render, or you have a list of the same jsx elements one after another, they need a key attribute (and CRA will warn you about it if you miss it).
If you are new to the concept of using the map()
function we saw in the previous video and you would like to learn more, we created a bonus video to explain the function in more detail. Simply go to Appendix 1: Key Developer Concepts at the bottom of the course video player, and watch the video on the map()
function.
Otherwise, let's keep going to the next video :)