Open History to see the last commit
1import { useQuery } from '@tanstack/preact-query'
2import { charactersQueries } from './services/characters/queries'
3β
4export default function Characters() {
5 const { status, data } = useQuery(charactersQueries.list())
6β
7 if (status === 'pending') return <p>Loading...</p>
8 if (status === 'error') return <p>Error :(</p>
9β
10 return (
11 <div>
12 <h2 className="text-4xl">Characters</h2>
13 {data.results.map((person) => {
14 return (
15 <article key={person.id}>
16 <a
17 className="text-blue-500 hover:underline"
18 href={`/characters/${person.id}`}
19 >
20 <h6 className="text-xl">
21 {person.name} - {person.gender}: {person.species}
22 </h6>
23 </a>
24 </article>
25 )
26 })}
27 </div>
28 )
29}