Implement person component#3785
Conversation
mateacademy-ai-mentor
left a comment
There was a problem hiding this comment.
Review Summary
I am approving your solution because all core functional requirements are correctly implemented: Person is used three times in App, the full person object is passed as a prop, age is conditionally omitted when missing, and the marriage text and class names behave exactly as specified. The only remaining issue is a checklist-related style point in src/components/Person/Person.jsx where the age conditional rendering is written inline as {age !== undefined && <p className="Person__age">Age: {age}</p>}; this technically violates [CHECKLIST ITEM #3], which asks for a separate variable for multi-part conditions. However, this is a readability/style concern rather than a functional blocker, and it does not break any required behavior, so it doesn't prevent task completion.
If you want to fully align with the checklist, you can do something like:
const hasAge = age !== undefined;
...
{hasAge && (
<p className="Person__age">Age: {age}</p>
)}Every other aspect of the component — prop destructuring, conditional partner text, and optional age handling — is well done, so overall this is a solid implementation.
✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨
Footnotes
| return ( | ||
| <section className="Person"> | ||
| <h2 className="Person__name">My name is {name}</h2> | ||
| {age !== undefined && <p className="Person__age">I am {age}</p>} |
There was a problem hiding this comment.
This violates checklist item #3: Avoid putting several cases to conditional rendering. Create separate variable for the condition. Currently, {age !== undefined && <p ...>} combines the condition and rendering inline; consider extracting const hasAge = age !== undefined; and then using {hasAge && ...} to comply with the guideline.
https://nibretu.github.io/react_person/