Skip to content

Checkpoint: Study Group Cards

The Course
•
20 min study

Close the earlier lessons, read the brief, and build it. Use the hints only after you've been stuck for a few minutes.

The brief

Build a page for a study group, with one ProfileCard component used three times. ProfileCard takes these props:

PropExampleShown as
name"Ada"A heading
role"Organiser"A line under the heading
minutes3005 hours studied. For 0, show Just getting started instead
isMentortrueA Mentor badge next to the name, and a highlighted card. Nothing for false
children<p>Ask me about components.</p>Under the rest, when given

Show Ada (Organiser, 300 minutes, mentor, with the children above), Grace (Learner, 120 minutes) and Linus (Learner, 0 minutes).

Acceptance checks:

  • Only Ada's card has the badge and the highlight.
  • Linus's card says Just getting started, not 0 hours studied, and no stray 0 appears anywhere.
  • No errors or warnings in the console.
Your workspace React · 3 files
import { createRoot } from "react-dom/client"; import App from "./App.jsx"; import "./styles.css"; createRoot(document.getElementById("root")).render(<App />); // Build three ProfileCards here. Put ProfileCard in src/ProfileCard.jsx, // or write it in this file first and move it later. export default function App() { return ( <main> <h1>Study group</h1> </main> ); } body { font: 16px/1.5 system-ui, sans-serif; margin: 0; color: #1c2430; } main { max-width: 32rem; margin: 1.5rem auto; padding: 0 1rem; } h1 { margin: 0 0 0.75rem; } .card { border: 1px solid #d6dde6; border-radius: 8px; padding: 0.75rem 1rem; margin-bottom: 0.75rem; } .card h2 { margin: 0 0 0.25rem; font-size: 1.1rem; } .muted { color: #6b7785; }
Runs with Vite on your computer: unzip, then npm install and npm run dev.
Hint 1: order of work

Get one card showing name and role first. Then add minutes, then the badge, then the highlight, then children. Run after each step.

Hint 2: two conditions

The badge is "something or nothing": &&, with a true or false value on the left. The hours line is "this or that": a ternary. The highlight is a class chosen with a ternary.

Show one solution
One solution React · 4 files
import { createRoot } from "react-dom/client"; import App from "./App.jsx"; import "./styles.css"; createRoot(document.getElementById("root")).render(<App />); import ProfileCard from "./ProfileCard.jsx"; export default function App() { return ( <main> <h1>Study group</h1> <ProfileCard name="Ada" role="Organiser" minutes={300} isMentor={true}> <p>Ask me about components.</p> </ProfileCard> <ProfileCard name="Grace" role="Learner" minutes={120} isMentor={false} /> <ProfileCard name="Linus" role="Learner" minutes={0} isMentor={false} /> </main> ); } export default function ProfileCard({ name, role, minutes, isMentor, children }) { return ( <section className={isMentor ? "card mentor" : "card"}> <h2> {name} {isMentor && <span className="badge">Mentor</span>} </h2> <p className="muted">{role}</p> <p>{minutes > 0 ? `${minutes / 60} hours studied` : "Just getting started"}</p> {children} </section> ); } body { font: 16px/1.5 system-ui, sans-serif; margin: 0; color: #1c2430; } main { max-width: 32rem; margin: 1.5rem auto; padding: 0 1rem; } h1 { margin: 0 0 0.75rem; } .card { border: 1px solid #d6dde6; border-radius: 8px; padding: 0.75rem 1rem; margin-bottom: 0.75rem; } .card h2 { margin: 0 0 0.25rem; font-size: 1.1rem; } .muted { color: #6b7785; } .mentor { border-color: #087ea4; background: #f3fbfd; } .badge { font-size: 0.75rem; padding: 0 0.5rem; border-radius: 999px; background: #087ea4; color: white; vertical-align: middle; }
Runs with Vite on your computer: unzip, then npm install and npm run dev.

Check yourself

  1. What is the difference between minutes="300" and minutes={300}? Predict minutes + 5 for each. Why might division appear to work anyway?
  2. When would you use children instead of a named prop?
  3. Why can {count && <p>...</p>} show a 0?

Was this article helpful?

Your response is saved on this device.