Download react-query/integrations/react-next-15/app/client-component.tsx from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 738 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/react-query/integrations/react-next-15/app/client-component.tsx
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset@1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/react-query/integrations/react-next-15/app/client-component.tsx
-
curl -L -o client-component.tsx https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/react-query/integrations/react-next-15/app/client-component.tsx
738 Bytes
| '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> | |
| ) | |
| } | |