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