forked from ShaneFindley/react-base
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdemo.tsx
40 lines (35 loc) · 1.15 KB
/
demo.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import { Card, CardContent, Skeleton, Typography } from '@mui/material'
import useAxios from 'axios-hooks'
export default function DemoAxios () {
const [result] = useAxios<{
id: number
name: string
height: number
weight: number
}>('https://pokeapi.co/api/v2/pokemon/ditto')
return <>
{
!result.loading && (result.data != null)
? <Card>
<CardContent>
<Typography gutterBottom variant="h5" component="div">
{result.data.name}
</Typography>
<Typography>Id: {result.data.id}</Typography>
<Typography>Height: {result.data.height}</Typography>
<Typography>Weight: {result.data.weight}</Typography>
</CardContent>
</Card>
: <Skeleton />
}
<pre style={{ padding: 20 }}>
{
` const [result] = useAxios<{
id: number,
name: string,
height: number,
weight: number
}>('https://pokeapi.co/api/v2/pokemon/ditto');` }
</pre>
</>
}