Open History to see the last commit
1import React from 'react'
2import { QueryClient, dehydrate, noop } from '@tanstack/react-query'
3import { Header, InfoBox, Layout, PostList } from '../components'
4import { postsQueryOptions } from '../hooks/usePosts'
5
6const Home = () => {
7 return (
8 <Layout>
9 <Header />
10 <InfoBox>ℹ️ This page shows how to use SSG with React-Query.</InfoBox>
11 <PostList />
12 </Layout>
13 )
14}
15
16export async function getStaticProps() {
17 const queryClient = new QueryClient()
18
19 await queryClient.query(postsQueryOptions(10)).catch(noop)
20
21 return {
22 props: {
23 dehydratedState: dehydrate(queryClient),
24 },
25 }
26}
27
28export default Home