snapshot of https://github.com/TanStack/query.git (main, 2026-09-16; blobs > 131072B omitted)
This commit is contained in:
36
integrations/react-next-16/app/client-component.tsx
Normal file
36
integrations/react-next-16/app/client-component.tsx
Normal file
@@ -0,0 +1,36 @@
|
||||
'use client'
|
||||
|
||||
import React from 'react'
|
||||
import { useQuery } from '@tanstack/react-query'
|
||||
import { Temporal } from '@js-temporal/polyfill'
|
||||
|
||||
export function ClientComponent() {
|
||||
const query = useQuery({
|
||||
queryKey: ['data'],
|
||||
queryFn: async () => {
|
||||
const { count } = await (
|
||||
await fetch('http://localhost:3000/count')
|
||||
).json()
|
||||
|
||||
return {
|
||||
text: 'data from client',
|
||||
date: Temporal.PlainDate.from('2023-01-01'),
|
||||
count,
|
||||
}
|
||||
},
|
||||
})
|
||||
|
||||
if (query.isPending) {
|
||||
return <div>Loading...</div>
|
||||
}
|
||||
|
||||
if (query.isError) {
|
||||
return <div>An error has occurred!</div>
|
||||
}
|
||||
|
||||
return (
|
||||
<div>
|
||||
{query.data.text} - {query.data.date.toJSON()} - {query.data.count}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user