Command Palette

Search for a command to run...

Hectal
Phase 12: TypeScript with React
React · Exercise 1 of 5Next
Beginner

Type a profile card's props

ProfileCard has no types, and the second card shows Role: undefined. Give it a props type and a default.

Write type ProfileCardProps (or an interface) with a required name: string and an optional role?: string, and annotate the component's props with it.

When role is left out, show Member. Keep the markup: each card is <article className="profile"> with an <h3> for the name and a <p className="role"> reading Role: <role>.

What Check tests

  1. Two profile cards are shown
  2. Asha's card shows Role: Admin
  3. A card without a role shows Role: Member
  4. Declares a props type with an optional role
  5. Annotates the component's props

Stuck? One hint at a time

The solution unlocks after your first Check. Try first: that is where the learning happens.

Runs in your browser. Your code is saved here.

Your page

Press Run to see the page.

Console

Nothing logged yet.