Skip to content

Commit 500418c

Browse files
authored
Preact front page quick look (#702)
* Preact front page quick look * lol
1 parent 96a28b1 commit 500418c

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/components/landing/QueryLanding.tsx

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,24 @@ function Todos() {
5353
return <ul>{todos.data?.map((t) => <li>{t.title}</li>)}</ul>
5454
}
5555
56+
export default Todos`,
57+
},
58+
preact: {
59+
lang: 'tsx',
60+
code: `import { useQuery } from '@tanstack/preact-query'
61+
62+
function Todos() {
63+
const { data, isPending, error } = useQuery({
64+
queryKey: ['todos'],
65+
queryFn: () => fetch('/api/todos').then(r => r.json()),
66+
})
67+
68+
if (isPending) return <span>Loading...</span>
69+
if (error) return <span>Oops!</span>
70+
71+
return <ul>{data.map(t => <li key={t.id}>{t.title}</li>)}</ul>
72+
}
73+
5674
export default Todos`,
5775
},
5876
vue: {

0 commit comments

Comments
 (0)