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
- Two profile cards are shown
- Asha's card shows Role: Admin
- A card without a role shows Role: Member
- Declares a props type with an optional role
- 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.