Data List Rendering
Difficulty: Warm-up
Problem Statementβ
Given an array of objects, render a list showing each item.
Live Demoβ
Try the running app below β this is the target behavior for the challenge.
Data List Rendering β Live Demo
Data List
- Daniel β 25
- John β 24
- Jen β 31
What Interviewers Expectβ
- Use
map()with stable keys. - Extract item row into a small component when useful.
- Keep data separate from rendering logic.
Step-by-Step Implementationβ
Step 1 β Define dataβ
Start with static array of objects.
const people = [{ id: 1, name: 'Daniel', age: 25 }];
Step 2 β Map to list itemsβ
Render <li> for each entry with key={person.id}.
{people.map((p) => <li key={p.id}>{p.name} β {p.age}</li>)}
Complete Implementationβ
Copy-paste ready single-file solution. Use this as your reference after attempting the challenge yourself, or paste it into CodeSandbox / StackBlitz to run locally.
App.jsx
import React from 'react';
const PEOPLE = [
{id: 1, name: 'Daniel', age: 25},
{id: 2, name: 'John', age: 24},
{id: 3, name: 'Jen', age: 31},
];
export default function App() {
return (
<div>
<h4>Data List</h4>
<ul>
{PEOPLE.map((person) => (
<li key={person.id}>
{person.name} β {person.age}
</li>
))}
</ul>
</div>
);
}
Final Checklistβ
- UI works for primary flow
- Edge cases handled (empty/disabled/loading where relevant)
- State updates are immutable
- Components are readable and reasonably split
- You can explain trade-offs out loud in an interview
Next Challengeβ
Continue to the next item in the sidebar when you're comfortable implementing this from scratch in 30β45 minutes.