Skip to content

Instantly share code, notes, and snippets.

@3nvi
Created June 5, 2020 15:16
Show Gist options
  • Save 3nvi/65c5be6751a8e92bfafa0b85df12cf0a to your computer and use it in GitHub Desktop.
Save 3nvi/65c5be6751a8e92bfafa0b85df12cf0a to your computer and use it in GitHub Desktop.
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