Skip to content

Instantly share code, notes, and snippets.

@dadamssg
Created March 4, 2019 19:01
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 dadamssg/7c0b19fe2ffe84634626cc4deb32b22a to your computer and use it in GitHub Desktop.
Save dadamssg/7c0b19fe2ffe84634626cc4deb32b22a to your computer and use it in GitHub Desktop.
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