Skip to content

Commit

Permalink
(example) using await params when dynamic routing (#72896)
Browse files Browse the repository at this point in the history
### Adding or Updating Examples

Hi, Team.
Updating example to await params as it is now used asynchronously.

Co-authored-by: JJ Kasper <[email protected]>
  • Loading branch information
hyungjikim and ijjk authored Nov 25, 2024
1 parent 43566f1 commit 90d6ef4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
7 changes: 4 additions & 3 deletions examples/dynamic-routing/app/post/[id]/[comment]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import Header from "../../../_components/header";

type Props = {
params: {
params: Promise<{
id: string;
comment: string;
};
}>;
};

export default function CommentPage({ params }: Props) {
export default async function CommentPage(props: Props) {
const params = await props.params;
return (
<>
<Header />
Expand Down
7 changes: 4 additions & 3 deletions examples/dynamic-routing/app/post/[id]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ import Link from "next/link";
import Header from "../../_components/header";

type Props = {
params: {
params: Promise<{
id: string;
};
}>;
};

export default function PostPage({ params }: Props) {
export default async function PostPage(props: Props) {
const params = await props.params;
return (
<>
<Header />
Expand Down

0 comments on commit 90d6ef4

Please sign in to comment.