From db3c57eaa4cc898ff02612c9f1cdecdb6960476c Mon Sep 17 00:00:00 2001 From: Sergey Arnautov Date: Mon, 14 Aug 2023 20:23:42 +0300 Subject: [PATCH] React person Fixed --- src/App.jsx | 12 +++------ src/components/Person/Person.jsx | 43 +++++++++++++------------------- 2 files changed, 21 insertions(+), 34 deletions(-) diff --git a/src/App.jsx b/src/App.jsx index 27003e94b..eb6735128 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -26,14 +26,8 @@ export const alex = { export const App = () => (
- - - + + +
); diff --git a/src/components/Person/Person.jsx b/src/components/Person/Person.jsx index a07c5df16..3b5f519a2 100644 --- a/src/components/Person/Person.jsx +++ b/src/components/Person/Person.jsx @@ -1,29 +1,22 @@ -export const Person = ({ person }) => ( -
-

- {`My name is ${person.name}`} -

+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 ( +
+

+ {`My name is ${name}`} +

+ + {age && (

- {`I am ${person.age}`} + {`I am ${age}`}

- ) - } + )} -

- { - person.isMarried ? ( - `${person.partnerName} is my ${person.sex === 'm' ? ( - 'wife' - ) : ( - 'husband' - )}` - ) : ( - `I am not married` - ) - } -

-
-); +

+ {partnerWifeHusband} +

+
+ ); +};