Skip to content
Source
Sign inSign up
TanStack/query
Open History to see the last commit

DogList.tsx

20 lines436 Bytes

1import { useQuery } from '@tanstack/react-query'
2import { dogsQueries } from './services/dogs/queries'
3​
4export const DogList = () => {
5 const { data, status } = useQuery(dogsQueries.list())
6​
7 if (status === 'pending') return 'Loading...'
8​
9 if (status === 'error') return 'Error!'
10​
11 const dogs = Object.keys(data.message)
12​
13 return (
14 <div>
15 {dogs.map((dog) => (
16 <div key={dog}>{dog}</div>
17 ))}
18 </div>
19 )