Skip to content

Instantly share code, notes, and snippets.

@simicd
Created August 16, 2020 18:56
Show Gist options
  • Select an option

  • Save simicd/eb96a960b25eff9015c5a33396a98a74 to your computer and use it in GitHub Desktop.

Select an option

Save simicd/eb96a960b25eff9015c5a33396a98a74 to your computer and use it in GitHub Desktop.
// DogImage.tsx
import React, { FC } from "react";
import { useFetch } from "./useFetch";
type DogImageType = { message: string; status: string };
export const DogImage: FC = () => {
const data = useFetch<DogImageType>({
url: "https://dog.ceo/api/breed/beagle/images/random"
});
return <>{data ? <img src={data.message} alt="dog"></img> : <div>Loading</div>}</>;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment