Last active
January 2, 2021 08:13
-
-
Save JWLangford/13b553d0b1188c9255d6c0e1a5e64326 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 * as React from "react"; | |
import "./styles.css"; | |
import useTest from "./hook"; | |
interface User { | |
name: string; | |
email: string; | |
age: number; | |
} | |
export default function App() { | |
const [getUser, errorMessage, user] = useTest<User>(); | |
return ( | |
<div className="App"> | |
<h1>Simple API Hook Demo</h1> | |
<button onClick={() => getUser("/users/123")}>Get User</button> | |
<div> | |
{user ? ( | |
<div> | |
<h5>{user.name}</h5> | |
<h6>{user.email}</h6> | |
<h6>{user.age}</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