Last active
April 4, 2021 20:51
-
-
Save Mazuh/9873f756d746d20c21f85d9099079956 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interface User { | |
name: string; | |
age: number; | |
} | |
interface AuthorizedUser extends User { | |
token: string; | |
} | |
type UserDisplayProps = { user: User }; | |
function UserDisplay(props: UserDisplayProps) { | |
return ( | |
<span> | |
{props.user.name} ({props.user.age} anos) | |
</span> | |
); | |
} | |
export default function App() { | |
const me: AuthorizedUser = { | |
name: "Marcell", | |
age: 23, | |
token: "abc42abc9-3/4" | |
}; | |
const friend1: User = { | |
name: "Lisa", | |
age: 23 | |
}; | |
const friend2: User = { | |
name: "Bob", | |
age: 68 | |
}; | |
return ( | |
<div className="App"> | |
<p> | |
Contatos de <UserDisplay user={me} />: | |
</p> | |
<ul> | |
<li> | |
<UserDisplay user={friend1} /> | |
</li> | |
<li> | |
<UserDisplay user={friend2} /> | |
</li> | |
</ul> | |
</div> | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment