Skip to content

Instantly share code, notes, and snippets.

@JWLangford
Last active January 2, 2021 08:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JWLangford/48eb6320d316d04ae04a76bbb86ac161 to your computer and use it in GitHub Desktop.
Save JWLangford/48eb6320d316d04ae04a76bbb86ac161 to your computer and use it in GitHub Desktop.
import * as React from "react";
import "./styles.css";
import useTest from "./hook";
interface Invoice {
id: string
amount: number
url: string
}
export default function App() {
const [getInvoice, errorMessage, invoice] = useTest<Invoice>();
return (
<div className="App">
<h1>Simple API Hook Demo</h1>
<button onClick={() => getInvoice("/invoice/123")}>Get Invoice</button>
<div>
{invoice ? (
<div>
<h5>{invoice.id}</h5>
<h6>{invoice.amount}</h6>
<h6>{invoice.url}</h6>
</div>
) : (
<h6 style={{ color: "red" }}>{errorMessage}</h6>
)}
</div>
</div>
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment