-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for incremental static regeneration
- Loading branch information
Showing
2 changed files
with
22 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,25 @@ | ||
import ItemList from 'components/ItemList'; | ||
import { useItems } from 'services/api-hooks'; | ||
import { Item } from 'services/data-types'; | ||
|
||
export default function Home() { | ||
const { data, isSuccess } = useItems(); | ||
interface HomeProps { | ||
items: Item[] | undefined; | ||
} | ||
|
||
export default function Home({ items }: HomeProps) { | ||
const { data, isSuccess } = useItems({ initialData: items }); | ||
|
||
return <div>{isSuccess && data && <ItemList items={data} />}</div>; | ||
} | ||
|
||
export async function getStaticProps() { | ||
const res = await fetch(`${process.env.SITE}/api/items`); | ||
const items = await res.json(); | ||
|
||
return { | ||
props: { | ||
items, | ||
}, | ||
revalidate: 30, | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62c46ed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs: