Skip to content

Commit

Permalink
React person Fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
Sirius9312 committed Aug 14, 2023
1 parent d4465bd commit db3c57e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 34 deletions.
12 changes: 3 additions & 9 deletions src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,8 @@ export const alex = {

export const App = () => (
<div className="App">
<Person
person={misha}
/>
<Person
person={olya}
/>
<Person
person={alex}
/>
<Person person={misha} />
<Person person={olya} />
<Person person={alex} />
</div>
);
43 changes: 18 additions & 25 deletions src/components/Person/Person.jsx
Original file line number Diff line number Diff line change
@@ -1,29 +1,22 @@
export const Person = ({ person }) => (
<section className="Person">
<h2 className="Person__name">
{`My name is ${person.name}`}
</h2>
export const Person = ({ person }) => {
const { name, age, sex, isMarried, partnerName } = person;
const partnerWifeHusband = isMarried ? (`${partnerName} is my ${sex === 'm' ? ('wife') : ('husband')}`) : (`I am not married`);

{
person.age && (
return (
<section className="Person">
<h2 className="Person__name">
{`My name is ${name}`}
</h2>

{age && (
<p className="Person__age">
{`I am ${person.age}`}
{`I am ${age}`}
</p>
)
}
)}

<p className="Person__partner">
{
person.isMarried ? (
`${person.partnerName} is my ${person.sex === 'm' ? (
'wife'
) : (
'husband'
)}`
) : (
`I am not married`
)
}
</p>
</section>
);
<p className="Person__partner">
{partnerWifeHusband}
</p>
</section>
);
};

0 comments on commit db3c57e

Please sign in to comment.