Component Composition Exercise

Build a restaurant listing page.

This tests whether you can break UI into clean components.

Requirements

Show:

Suggested components

App
Header
SearchBox
RestaurantList
RestaurantCard
EmptyState

Data example

const restaurants = [
  {
    id: 1,
    name: 'Spice House',
    rating: 4.4,
    cuisines: ['North Indian', 'Chinese'],
  },
]

What to practice

Common mistake

Do not use array index as key when list order can change.

Use a stable id:

{restaurants.map((restaurant) => (
  <RestaurantCard key={restaurant.id} restaurant={restaurant} />
))}