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

react_person #2368

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

react_person #2368

wants to merge 4 commits into from

Conversation

Yaroslav65
Copy link

No description provided.

Comment on lines 18 to 22
{person.age !== undefined ? (
<p className="Person__age">
<p>{`I am ${person.age}`}</p>
</p>
) : null}

Choose a reason for hiding this comment

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

Suggested change
{person.age !== undefined ? (
<p className="Person__age">
<p>{`I am ${person.age}`}</p>
</p>
) : null}
{person.age && (
<p className="Person__age">
<p>{`I am ${person.age}`}</p>
</p>
)}

Comment on lines 3 to 13
const Married = ({ person }) => {
if (person.isMarried === false) {
return <p>I am not married</p>;
}

if (person.sex === 'f') {
return <p>{person.partnerName} is my husband</p>;
}

return <p>{person.partnerName} is my wife</p>;
};

Choose a reason for hiding this comment

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

better to write it directly in Person, using ternary operators

Copy link
Author

Choose a reason for hiding this comment

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

I agree, I already tried to do this but there was one error in the linter when I used two ternary operators (? : ? : )there was something like a wrong rule, although everything worked

Copy link
Author

Choose a reason for hiding this comment

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

That's why I put it in a function so that there is no error in the linter

Copy link
Author

Choose a reason for hiding this comment

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

better to write it directly in Person, using ternary operators

is this error - 12:8 error Do not nest ternary expressions no-nested-ternary

Choose a reason for hiding this comment

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

you can just move some condition in variable and reuse in ternary operator

Copy link
Author

Choose a reason for hiding this comment

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

you can just move some condition in variable and reuse in ternary operator

thanks for helps))

@Yaroslav65 Yaroslav65 requested a review from etojeDenys May 20, 2024 15:55
Copy link

@etojeDenys etojeDenys left a comment

Choose a reason for hiding this comment

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

feel free to ask for some help in the chat

Comment on lines 3 to 13
const Married = ({ person }) => {
if (person.isMarried === false) {
return <p>I am not married</p>;
}

if (person.sex === 'f') {
return <p>{person.partnerName} is my husband</p>;
}

return <p>{person.partnerName} is my wife</p>;
};

Choose a reason for hiding this comment

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

you can just move some condition in variable and reuse in ternary operator

@Yaroslav65
Copy link
Author

feel free to ask for some help in the chat

please double check my code

@Yaroslav65 Yaroslav65 requested a review from etojeDenys May 20, 2024 16:01
Copy link

@vadiimvooo vadiimvooo left a comment

Choose a reason for hiding this comment

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

Good job. Last thing to fix.

Comment on lines 3 to 20
export const Person = ({ person }) => (
<section className="Person">
<h2 className="Person__name">{`My name is ${person.name}`}</h2>
{person.age && (
<p className="Person__age">
<p>{`I am ${person.age}`}</p>
</p>
)}
<p className="Person__partner">
{person.isMarried === false ? (
<p>I am not married</p>
) : person.sex === 'f' ? (
<p>{person.partnerName} is my husband</p>
) : (
<p>{person.partnerName} is my wife</p>
)}
</p>
</section>

Choose a reason for hiding this comment

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

Suggested change
export const Person = ({ person }) => (
<section className="Person">
<h2 className="Person__name">{`My name is ${person.name}`}</h2>
{person.age && (
<p className="Person__age">
<p>{`I am ${person.age}`}</p>
</p>
)}
<p className="Person__partner">
{person.isMarried === false ? (
<p>I am not married</p>
) : person.sex === 'f' ? (
<p>{person.partnerName} is my husband</p>
) : (
<p>{person.partnerName} is my wife</p>
)}
</p>
</section>
export const Person = ({ person }) => {
const { name, age, sex, isMarried, partnerName } = person;
const partner = sex === 'm' ? 'wife' : 'husband';
const personPartner = isMarried
? `${partnerName} is my ${partner}`
: `I am not married`;
return (<section className="Person">
<h2 className="Person__name">{`My name is ${name}`}</h2>
{age && (
<p className="Person__age">
<p>{`I am ${age}`}</p>
</p>
)}
<p className="Person__partner">{personPartner}</p>
</section>)
}

Copy link
Author

Choose a reason for hiding this comment

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

thanks for helps))

@Yaroslav65 Yaroslav65 requested a review from vadiimvooo May 20, 2024 16:58
Comment on lines 16 to 22
{person.isMarried === false ? (
<p>I am not married</p>
) : (
<p>
{person.partnerName} is my {partner}
</p>
)}

Choose a reason for hiding this comment

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

Suggested change
{person.isMarried === false ? (
<p>I am not married</p>
) : (
<p>
{person.partnerName} is my {partner}
</p>
)}
{person.isMarried === false ? (
"I am not married"
) : (
`${person.partnerName} is my {partner}`
)}

looks like redundant p tag

@Yaroslav65 Yaroslav65 requested a review from etojeDenys May 20, 2024 17:13
Copy link

@etojeDenys etojeDenys left a comment

Choose a reason for hiding this comment

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

awesome

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.

3 participants