Skip to content

Instantly share code, notes, and snippets.

@Mazuh
Last active April 4, 2021 20:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Mazuh/9873f756d746d20c21f85d9099079956 to your computer and use it in GitHub Desktop.
Save Mazuh/9873f756d746d20c21f85d9099079956 to your computer and use it in GitHub Desktop.
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