Created
June 5, 2020 15:16
-
-
Save 3nvi/65c5be6751a8e92bfafa0b85df12cf0a to your computer and use it in GitHub Desktop.
This file contains 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
import React from "react"; | |
import { useParams, Link } from "react-router-dom"; | |
import { get } from 'lodash'; | |
import useQuery from "./useQuery"; | |
const DogPage = () => { | |
const { breed } = useParams(); | |
const { data } = useQuery({ | |
url: `https://dog.ceo/api/breed/${breed}/images/random` | |
}); | |
const imageSrc = get(data, "message"); | |
return ( | |
<div> | |
<div> | |
<Link to="/">back</Link> | |
</div> | |
{!imageSrc && <p>Loading...</p>} | |
{imageSrc && <img alt={`A nice ${breed}`} src={imageSrc} height={200} />} | |
</div> | |
); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment