Created
March 4, 2019 19:01
-
-
Save dadamssg/7c0b19fe2ffe84634626cc4deb32b22a 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
function Profile ({userId}) { | |
const [profile, setProfile] = useState(null) | |
useEffect(() => { | |
fetch(`/api/users/${userId}`) | |
.then(res => { | |
setProfile(res.json().profile) | |
}) | |
}, [userId]) // run when it has new userId | |
return ( | |
<div>{profile && profile.full_name}</div> | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment