-
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
initial commit #1588
base: master
Are you sure you want to change the base?
initial commit #1588
Conversation
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.
Good progress 👍
But some comments below
src/components/Person/Person.jsx
Outdated
return ( | ||
<> | ||
<section className="Person"> | ||
<h2 className="Person__name">{ `My name is ${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.
<h2 className="Person__name">{ `My name is ${name}` }</h2> | |
<h2 className="Person__name">{`My name is ${name}`}</h2> |
src/components/Person/Person.jsx
Outdated
{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.
{age | |
&& ( | |
<p className="Person__age"> | |
{`I am ${age}`} | |
</p> | |
) | |
} | |
{age && ( | |
<p className="Person__age"> | |
{`I am ${age}`} | |
</p> | |
)} |
src/components/Person/Person.jsx
Outdated
{sex === 'f' | ||
? `${partnerName} is my husband` | ||
: `${partnerName} is my wife` |
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.
Try not to nest ternary, create constant for this
src/components/Person/Person.jsx
Outdated
export function Person({ person }) { | ||
const { | ||
name, | ||
age = null, |
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.
age = null, | |
age, |
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.
This tag is the same for both variants, you don't need to duplicate it
…for props, delete nest ternarn
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.
Almost done!
src/components/Person/Person.jsx
Outdated
<> | ||
<section className="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.
<> | |
<section className="Person"> | |
<section className="Person"> |
There is no need to use React fragment here as you already have a container
src/components/Person/Person.jsx
Outdated
partnerName, | ||
} = person; | ||
|
||
const whoIsPartner = sex === 'f' |
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.
src/components/Person/Person.jsx
Outdated
{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.
{age | |
&& ( | |
<p className="Person__age"> | |
{`I am ${age}`} | |
</p> | |
)} | |
{age && ( | |
<p className="Person__age"> | |
{`I am ${age}`} | |
</p> | |
)} |
src/components/Person/Person.jsx
Outdated
)} | ||
|
||
<p className="Person__partner"> | ||
{isMarried ? `${whoIsPartner}` : 'I am not married'} |
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.
<section className="Person"> | ||
<h2 className="Person__name">{`My name is ${name}`}</h2> | ||
|
||
{age && ( |
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.
I guess if age is gonna be 0 it's not gonna work correctly, I mean age 0 is not correctly itself, but react will probably just render '0' on the page, so we have to convert it to boolean to make sure it works just fine, we can achieve it by using !! or Boolean
partnerName, | ||
} = person; | ||
|
||
const getPartner = sex === 'f' |
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.
get sounds like an action, good prefix for function, but not variable
I'd like you to name it as partnerInfo or something like this, you decide
btw, demo link redirects to blank page |
DEMO LINK