-
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
finish solution #1619
base: master
Are you sure you want to change the base?
finish solution #1619
Conversation
src/components/Person/Person.jsx
Outdated
|
||
export const Person = (props) => { | ||
const { name, age, sex, isMarried, partnerName } = props.person; | ||
let partner = `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.
It's not clear why not marriage info string is stored in partner
variable
Check please variable name
src/components/Person/Person.jsx
Outdated
{age | ||
? <p className="Person__age">{`I am ${age}`}</p> | ||
: 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.
It's redundant to use null
here
Rewrite it using &&
operator
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.
Small comments below
src/components/Person/Person.jsx
Outdated
export const Person = (props) => { | ||
const { name, age, sex, isMarried, partnerName } = props.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.
export const Person = (props) => { | |
const { name, age, sex, isMarried, partnerName } = props.person; | |
export const Person = ({ person }) => { | |
const { | |
name, | |
age, | |
sex, | |
isMarried, | |
partnerName, | |
} = 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.
We can use destructuring for props. Also pay attention to good formatting
src/components/Person/Person.jsx
Outdated
</h2> | ||
{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.
</h2> | |
{age && <p className="Person__age">{`I am ${age}`}</p>} | |
</h2> | |
{!!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.
It is easier to read. Also if age=0
we will see 0 on the page. !! solves this problem
{`My name is ${name}`} | ||
</h2> | ||
{age && <p className="Person__age">{`I am ${age}`}</p>} | ||
<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.
<p className="Person__partner"> | |
<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.
LGTM 👍
src/components/Person/Person.jsx
Outdated
</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.
</h2> | |
{!!age && ( | |
</h2> | |
{!!age && ( |
Demo link