Skip to content

Instantly share code, notes, and snippets.

@narf200
Last active August 8, 2020 20:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save narf200/d26684b6cb98e56d49baaff6dc18e076 to your computer and use it in GitHub Desktop.
Save narf200/d26684b6cb98e56d49baaff6dc18e076 to your computer and use it in GitHub Desktop.
import React, { useState, useEffect } from 'react'
import axios from 'axios'
const User = () => {
const [user, setUser] = useState({})
useEffect(() => {
axios.get('https://jsonplaceholder.typicode.com/users/1').then(it => {
setUser(it.data)
})
}, [])
return <div>
<div>{user.username}</div>
<div>{user.email}</div>
<div>{user.website}</div>
<div>{user.phone}</div>
</div>
}
ReactDOM.render(<User />, mountNode)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment