Skip to content

Create App Component #9

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ASPhillips8
Copy link

@ASPhillips8 ASPhillips8 commented Jun 17, 2024

Created app component that uses State to render dog pics. Used useEffect hook to fetch dog data. Created element with text of "Loading..." when the component is first rendered. Rendered a random dog picture from data returned from fetch.

Screenshot 2024-06-17 at 11 52 00 AM

const url = "https://dog.ceo/api/breeds/image/random"

function App() {
const [getDogPic, setGetDogPic] = useState(null)

Choose a reason for hiding this comment

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

You wouldn't need to call the getDogPic. dogPic would be a better name since there's no fetching or data retrieval happening for the variable.

Suggested change
const [getDogPic, setGetDogPic] = useState(null)
const [dogPic, setGetDogPic] = useState(null)

Comment on lines +17 to +19
<div>
<img src={getDogPic} alt="A Random Dog" />
</div>

Choose a reason for hiding this comment

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

The div here is unnecessary.

Suggested change
<div>
<img src={getDogPic} alt="A Random Dog" />
</div>
<img src={getDogPic} alt="A Random Dog" />

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants