Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 additions & 1 deletion src/components/App.js
Original file line number Diff line number Diff line change
@@ -1 +1,23 @@
// create your App component here
import React, { useState, useEffect } from "react";

function App() {
const [image, setImage] = useState(null)

useEffect(() => {
fetch('https://dog.ceo/api/breeds/image/random')
.then(res => res.json())
.then(data => setImage(data.message))
}, [])

if (!image) {
return <p>Loading...</p>
}

return (
<div>
<img src={image} alt="A Random Dog" />
</div>
)
Comment on lines +16 to +20

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to wrap in a div here:

Suggested change
return (
<div>
<img src={image} alt="A Random Dog" />
</div>
)
return (
<img src={image} alt="A Random Dog" />
)

}

export default App;