Skip to content
Source
Sign inSign up
TanStack/query
Open History to see the last commit

index.js

28 lines626 Bytes

1import React from 'react'
2import { dehydrate, QueryClient } from 'react-query'
3import { Layout, Header, InfoBox, PostList } from '../components'
4import { fetchPosts } from '../hooks'
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 )
15​
16export async function getStaticProps() {
17 const queryClient = new QueryClient()
18​
19 await queryClient.prefetchQuery(['posts', 10], () => fetchPosts(10))
20​
21 return {
22 props: {
23 dehydratedState: dehydrate(queryClient),
24 },
25 }
27​
28export default Home