What you are practising: rendering a list with map and correct keys, holding state with useState, and updating it immutably.
Accept the assignment, clone your repository, then install once:
npm installnpm run devOpen the URL it prints (usually http://localhost:5173). npm run typecheck runs the compiler on its own.
src/data.ts: the ten destinations (id,name,imageUrl). No phases yet; those arrive in Session 7 with the API.src/components/Card.tsx: the<Card>from Session 5, carried forward so you can focus on lists and state.public/destinations/: placeholder images for all ten destinations.src/index.css: the Session 5 baseline plus a.gridlayout, a.card.selectedstate, and a.donestrikethrough.
- Render the list of destinations with correct keys.
- Track a
selectedId: string | nullin state. - Clicking a card sets the selected id. Clicking the selected card again clears it.
- The selected card renders with a visible selected style (conditional rendering; the
.card.selectedclass is ready). - Show a header that reads
No destination selectedorYou picked {name}depending on state.
Extending <Card>'s props (a selected look, an onClick handler) is part of the exercise, not cheating.
- Add a "clear selection" button that renders only when something is selected.
- Sort the destinations by name with
.sort(). Why does sorting in place break things here? Fix it with[...destinations].sort(). - Add a count of unselected destinations.
All ten destinations render with no key warning in the browser console, selection toggles on and off visibly, the header follows the selection, npm run typecheck passes, and your work is committed and pushed.
Every push runs two GitHub Actions checks:
- Type check — runs
tsc -bon your project. - Autograding — renders your
<App />with React Testing Library and checks that all ten destinations render, the header starts at "No destination selected", clicking a card selects it (header updates and the card gets the.selectedstyle), and clicking it again clears the selection — plus an automated code-quality review. Keep the header wording and the destination names fromsrc/data.tsintact so the grader can find them.