What is the issue with this code in terms of key assignment?
const list = ["apple", "banana", "cherry"];
return (
<ul>
{list.map((fruit, index) => (
<li key={index}>{fruit}</li>
))}
</ul>
);
Using index as a key is fine in all cases
index should not be used as a key when the list can change dynamically
The key should always be a string
key should be assigned to the ul tag
This question is part of this quiz :
Lists and Keys in React