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