Lists and Keys
Use map to turn an array into elements. Each item needs a stable, unique key so React can track it.
Example
const items = [{ id: 1, name: 'Pen' }, { id: 2, name: 'Book' }];
<ul>
{items.map((i) => (
<li key={i.id}>{i.name}</li>
))}
</ul>Exercise
Add the special attribute.
<li ={i.id}>
Quiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.