freeCodeCamp Challenge Guide: Give Sibling Elements a Unique Key Attribute

Give Sibling Elements a Unique Key Attribute


Hints

Hint 1

It is just almost same as previous challenge. Just you need to add key attribute.


Solutions

Solution 1 (Click to Show/Hide)

Add the key attribute to the <li> and give it a unique value.

Using the array element as the key:

const renderFrameworks = frontEndFrameworks.map((item) =>
  <li key={item}>{item}</li>
);

Using the array index as the key (should be avoided):

const renderFrameworks = frontEndFrameworks.map((item, index) =>
  <li key={index}>{item}</li>
);

Relevant Links

14 Likes