-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
solution #1601
base: master
Are you sure you want to change the base?
solution #1601
Conversation
src/App.jsx
Outdated
<p className="Person__partner">Natasha is my wife</p> | ||
</section> | ||
<Person | ||
className="Person__name" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Your component doesn't need such prop
src/App.jsx
Outdated
<Person | ||
className="Person__name" | ||
person={misha} | ||
/> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Delete blank lines between components
src/components/Person/Person.jsx
Outdated
// export const Person = ({ person }) => (); | ||
export const Person = ({ person }) => ( | ||
<section className="Person"> | ||
<h2 className="Person__name">{`My name is ${person.name}`}</h2> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use destructuring
src/components/Person/Person.jsx
Outdated
{ | ||
Object.hasOwn(person, 'age') && ( | ||
<p className="Person__age">{`I am ${person.age}`}</p> | ||
) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
{ | |
Object.hasOwn(person, 'age') && ( | |
<p className="Person__age">{`I am ${person.age}`}</p> | |
) | |
} | |
{Boolean(age) && ( | |
<p className="Person__age"> | |
{`I am ${person.age}`} | |
</p> | |
)} |
src/components/Person/Person.jsx
Outdated
person.isMarried ? ( | ||
<p className="Person__partner"> | ||
{person.sex === 'm' ? ( | ||
`${person.partnerName} is my wife` | ||
) : ( | ||
`${person.partnerName} is my husband` | ||
)} | ||
</p> | ||
) : ( | ||
<p className="Person__partner">I am not married</p> | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Avoid using nested conditions
src/App.jsx
Outdated
<Person | ||
person={misha} | ||
/> | ||
<Person | ||
person={olya} | ||
/> | ||
<Person | ||
person={alex} | ||
/> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<Person | |
person={misha} | |
/> | |
<Person | |
person={olya} | |
/> | |
<Person | |
person={alex} | |
/> | |
<Person person={misha} /> | |
<Person person={olya} /> | |
<Person person={alex} /> |
src/components/Person/Person.jsx
Outdated
{ | ||
Boolean(age) && ( | ||
<p className="Person__age"> | ||
{`I am ${age}`} | ||
</p> | ||
) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
{ | |
Boolean(age) && ( | |
<p className="Person__age"> | |
{`I am ${age}`} | |
</p> | |
) | |
} | |
{Boolean(age) && ( | |
<p className="Person__age"> | |
{`I am ${age}`} | |
</p> | |
)} |
src/components/Person/Person.jsx
Outdated
|
||
{ | ||
isMarried ? ( | ||
<p className="Person__partner"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remember about DRY. You use this tag twice for both variants. Why not change only containing this tag depending on isMarried
src/components/Person/Person.jsx
Outdated
@@ -1 +1,33 @@ | |||
// export const Person = ({ person }) => (); | |||
export const Person = ({ person }) => { | |||
const { name, age, isMarried, partnerName, sex } = person; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const { name, age, isMarried, partnerName, sex } = person; | |
const { | |
name, | |
age, | |
isMarried, | |
partnerName, | |
sex, | |
} = person; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for this silly mistake.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
DEMO LINK