Download react-query/examples/react/nextjs/src/pages/index.tsx from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 679 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/react-query/examples/react/nextjs/src/pages/index.tsx
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset@1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/react-query/examples/react/nextjs/src/pages/index.tsx
-
curl -L -o index.tsx https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/react-query/examples/react/nextjs/src/pages/index.tsx
679 Bytes
| import React from 'react' | |
| import { QueryClient, dehydrate } from '@tanstack/react-query' | |
| import { Header, InfoBox, Layout, PostList } from '../components' | |
| import { fetchPosts } from '../hooks/usePosts' | |
| const Home = () => { | |
| return ( | |
| <Layout> | |
| <Header /> | |
| <InfoBox>ℹ️ This page shows how to use SSG with React-Query.</InfoBox> | |
| <PostList /> | |
| </Layout> | |
| ) | |
| } | |
| export async function getStaticProps() { | |
| const queryClient = new QueryClient() | |
| await queryClient.prefetchQuery({ | |
| queryKey: ['posts', 10], | |
| queryFn: () => fetchPosts(10), | |
| }) | |
| return { | |
| props: { | |
| dehydratedState: dehydrate(queryClient), | |
| }, | |
| } | |
| } | |
| export default Home | |