react-code-dataset / react-query /examples /react /nextjs-suspense-streaming /src /app /providers.tsx
Download react-query/examples/react/nextjs-suspense-streaming/src/app/providers.tsx from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 1.04 kB
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/react-query/examples/react/nextjs-suspense-streaming/src/app/providers.tsx
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset@1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/react-query/examples/react/nextjs-suspense-streaming/src/app/providers.tsx
-
curl -L -o providers.tsx https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/react-query/examples/react/nextjs-suspense-streaming/src/app/providers.tsx
1.04 kB
| 'use client' | |
| import { | |
| QueryClient, | |
| QueryClientProvider, | |
| isServer, | |
| } from '@tanstack/react-query' | |
| import { ReactQueryDevtools } from '@tanstack/react-query-devtools' | |
| import * as React from 'react' | |
| import { ReactQueryStreamedHydration } from '@tanstack/react-query-next-experimental' | |
| function makeQueryClient() { | |
| return new QueryClient({ | |
| defaultOptions: { | |
| queries: { | |
| staleTime: 60 * 1000, | |
| }, | |
| }, | |
| }) | |
| } | |
| let browserQueryClient: QueryClient | undefined = undefined | |
| function getQueryClient() { | |
| if (isServer) { | |
| return makeQueryClient() | |
| } else { | |
| if (!browserQueryClient) browserQueryClient = makeQueryClient() | |
| return browserQueryClient | |
| } | |
| } | |
| export function Providers(props: { children: React.ReactNode }) { | |
| const queryClient = getQueryClient() | |
| return ( | |
| <QueryClientProvider client={queryClient}> | |
| <ReactQueryStreamedHydration> | |
| {props.children} | |
| </ReactQueryStreamedHydration> | |
| <ReactQueryDevtools initialIsOpen={false} /> | |
| </QueryClientProvider> | |
| ) | |
| } | |