Created
March 21, 2020 12:09
-
-
Save DJanoskova/14903fef5e46e6a3a8ff447d47554426 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| import React, { useState } from "react"; | |
| import PropTypes from "prop-types"; | |
| export const UserCard = ({ user }) => { | |
| return ( | |
| <ul> | |
| <li>{user.name}</li> | |
| <li>{user.age}</li> | |
| <li>{user.email}</li> | |
| </ul> | |
| ); | |
| }; | |
| UserCard.propTypes = { | |
| user: PropTypes.object.isRequired | |
| }; | |
| export const UserContainer = () => { | |
| const [user, setUser] = useState(null); | |
| // do some apiCall here | |
| return ( | |
| <div> | |
| {user && <UserCard user={user} />} | |
| </div> | |
| ); | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment