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
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