Open History to see the last commit
1'use client'
2β
3import { useQuery } from '@tanstack/react-query'
4β
5export function ClientComponent() {
6 const query = useQuery({
7 queryKey: ['test'],
8 queryFn: async () => {
9 await new Promise((r) => setTimeout(r, 1000))
10 return 'Success'
11 },
12 })
13β
14 if (query.isPending) {
15 return <div>Loading...</div>
16 }
17β
18 if (query.isError) {
19 return <div>An error has occurred!</div>
20 }
21β
22 return <div>{query.data}</div>
23}