Skip to content
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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

solution #1601

wants to merge 3 commits into from

Conversation

AndrMar1939
Copy link

src/App.jsx Outdated
<p className="Person__partner">Natasha is my wife</p>
</section>
<Person
className="Person__name"

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}
/>

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

// export const Person = ({ person }) => ();
export const Person = ({ person }) => (
<section className="Person">
<h2 className="Person__name">{`My name is ${person.name}`}</h2>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use destructuring

Comment on lines 5 to 9
{
Object.hasOwn(person, 'age') && (
<p className="Person__age">{`I am ${person.age}`}</p>
)
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
{
Object.hasOwn(person, 'age') && (
<p className="Person__age">{`I am ${person.age}`}</p>
)
}
{Boolean(age) && (
<p className="Person__age">
{`I am ${person.age}`}
</p>
)}

Comment on lines 12 to 22
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>
)

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
Comment on lines 29 to 37
<Person
person={misha}
/>
<Person
person={olya}
/>
<Person
person={alex}
/>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<Person
person={misha}
/>
<Person
person={olya}
/>
<Person
person={alex}
/>
<Person person={misha} />
<Person person={olya} />
<Person person={alex} />

Comment on lines 14 to 20
{
Boolean(age) && (
<p className="Person__age">
{`I am ${age}`}
</p>
)
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
{
Boolean(age) && (
<p className="Person__age">
{`I am ${age}`}
</p>
)
}
{Boolean(age) && (
<p className="Person__age">
{`I am ${age}`}
</p>
)}


{
isMarried ? (
<p className="Person__partner">

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

@@ -1 +1,33 @@
// export const Person = ({ person }) => ();
export const Person = ({ person }) => {
const { name, age, isMarried, partnerName, sex } = person;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const { name, age, isMarried, partnerName, sex } = person;
const {
name,
age,
isMarried,
partnerName,
sex,
} = person;

Copy link
Author

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.

Copy link

@Moroz-Dmytro Moroz-Dmytro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants