Skip to content

Commit

Permalink
docs(routing): update params type to be async (v15) (#73111)
Browse files Browse the repository at this point in the history
## Why?

Update params type to be async (v15).

- x-ref: #72070
  • Loading branch information
samcx authored and wyattjoh committed Nov 28, 2024
1 parent 7b4e2ff commit aec82cb
Showing 1 changed file with 19 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,21 @@ async function fetchTeam(id: string) {
return res.json()
}

export default async function Profile({ params }: { params: { id: string } }) {
const team = await fetchTeam(params.id)
if (!team) {
export default async function Profile({
params,
}: {
params: Promise<{ id: string }>
}) {
const id = (await params).id
if (!id) {
redirect('/login')
}

const team = await fetchTeam(id)
if (!team) {
redirect('/join')
}

// ...
}
```
Expand All @@ -97,11 +106,16 @@ async function fetchTeam(id) {
}

export default async function Profile({ params }) {
const team = await fetchTeam(params.id)
if (!team) {
const id = (await params).id
if (!id) {
redirect('/login')
}

const team = await fetchTeam(id)
if (!team) {
redirect('/join')
}

// ...
}
```
Expand Down

0 comments on commit aec82cb

Please sign in to comment.