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