Skip to content

Commit

Permalink
docs: fix static params as promise examples (vercel#72553)
Browse files Browse the repository at this point in the history
## Improving Documentation

dynamic `params` from `generateStaticParams` is now a promise but is now
promise in type.
Type has been changed for every Promise `params`.

Co-authored-by: Delba de Oliveira <[email protected]>
Co-authored-by: JJ Kasper <[email protected]>
  • Loading branch information
3 people authored Nov 22, 2024
1 parent f34e02d commit 4a203a0
Showing 1 changed file with 17 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,11 @@ export function generateStaticParams() {
// - /product/1
// - /product/2
// - /product/3
export default async function Page({ params }: { params: { id: string } }) {
export default async function Page({
params,
}: {
params: Promise<{ id: string }>
}) {
const { id } = await params
// ...
}
Expand Down Expand Up @@ -106,7 +110,7 @@ export function generateStaticParams() {
export default async function Page({
params,
}: {
params: { category: string; product: string }
params: Promise<{ category: string; product: string }>
}) {
const { category, product } = await params
// ...
Expand Down Expand Up @@ -145,7 +149,11 @@ export function generateStaticParams() {
// - /product/a/1
// - /product/b/2
// - /product/c/3
export default async function Page({ params }: { params: { slug: string[] } }) {
export default async function Page({
params,
}: {
params: Promise<{ slug: string[] }>
}) {
const { slug } = await params
// ...
}
Expand Down Expand Up @@ -263,7 +271,7 @@ export async function generateStaticParams() {
export default function Page({
params,
}: {
params: { category: string; product: string }
params: Promise<{ category: string; product: string }>
}) {
// ...
}
Expand Down Expand Up @@ -299,7 +307,11 @@ export async function generateStaticParams() {
}))
}

export default function Layout({ params }: { params: { category: string } }) {
export default function Layout({
params,
}: {
params: Promise<{ category: string }>
}) {
// ...
}
```
Expand Down

0 comments on commit 4a203a0

Please sign in to comment.